8000 GitHub - saliola/nonnegative_integer_matrices: code to generate and count nonnegative integer matrices with prescribe row and column sums (aka contingency tables)
[go: up one dir, main page]

Skip to content

code to generate and count nonnegative integer matrices with prescribe row and column sums (aka contingency tables)

Notifications You must be signed in to change notification settings

saliola/nonnegative_integer_matrices

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Generating nonnegative integer matrices with prescribed row and column sums

Implementations in different languages of an algorithm to generate nonnegative integer matrices with prescribed row and column sums. These are also known as contingency tables.

python

The file nonneg_int_matrices.py contains an example/test.

$ cd python
$ python nonneg_int_matrices.py
[[0, 3], [0, 1], [5, 0]]
[[0, 3], [1, 0], [4, 1]]
[[1, 2], [0, 1], [4, 1]]
[[1, 2], [1, 0], [3, 2]]
[[2, 1], [0, 1], [3, 2]]
[[2, 1], [1, 0], [2, 3]]
[[3, 0], [0, 1], [2, 3]]
[[3, 0], [1, 0], [1, 4]]

numpy

Install numpy if it is not already installed:

$ pip install numpy

The file nonneg_int_matrices.py contains an example/test.

$ cd numpy
$ python nonneg_int_matrices.py
[[0 3]
 [0 1]
 [5 0]]
[[0 3]
 [1 0]
 [4 1]]
[[1 2]
 [0 1]
 [4 1]]
[[1 2]
 [1 0]
 [3 2]]
[[2 1]
 [0 1]
 [3 2]]
[[2 1]
 [1 0]
 [2 3]]
[[3 0]
 [0 1]
 [2 3]]
[[3 0]
 [1 0]
 [1 4]]

cython

Install cython if it is not already installed:

$ pip install cython

The file nonneg_int_matrices.py contains an example/test.

$ cd cython
$ make
$ python nonneg_int_matrices.py
[[0, 3], [0, 1], [5, 0]]
[[0, 3], [1, 0], [4, 1]]
[[1, 2], [0, 1], [4, 1]]
[[1, 2], [1, 0], [3, 2]]
[[2, 1], [0, 1], [3, 2]]
[[2, 1], [1, 0], [2, 3]]
[[3, 0], [0, 1], [2, 3]]
[[3, 0], [1, 0], [1, 4]]

cython with numpy

Install cython and numpy if not already installed:

$ pip install cython
$ pip install numpy

The file nonneg_int_matrices.py contains an example/test.

$ cd cython-with-numpy
$ make
$ python nonneg_int_matrices.py
[[0 3]
 [0 1]
 [5 0]]
[[0 3]
 [1 0]
 [4 1]]
[[1 2]
 [0 1]
 [4 1]]
[[1 2]
 [1 0]
 [3 2]]
[[2 1]
 [0 1]
 [3 2]]
[[2 1]
 [1 0]
 [2 3]]
[[3 0]
 [0 1]
 [2 3]]
[[3 0]
 [1 0]
 [1 4]]

About

code to generate and count nonnegative integer matrices with prescribe row and column sums (aka contingency tables)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0