# ASA144 Random generation of a table.

ASA144 is a FORTRAN90 library which randomly generates an RxC contingency table, by James Boyett.

ASA144 is Applied Statistics Algorithm 144.

ASA144 accepts a table shape (the number of rows and columns), and two vectors, the lists of row and column sums. There may be 0, 1, or many tables with nonnegative, integral entries that have the given shape and sums. The program will generate, at random, one of the tables and return it. Repeated calls to the program will return new random selections.

For example, suppose M = 2, N = 3, row sum = (/ 6, 5 /) and column sum = (/ 3, 4, 4 /), then here are two tables that satisfy the constraints:

```        1  2  3
2  2  1
```
and
```        3  0  3
0  4  1
```

### Languages:

ASA144 is available in a C version and a C++ version and a FORTRAN77 version and a FORTRAN90 version and a MATLAB version.

### Related Data and Programs:

ASA159, a FORTRAN90 routine which randomly generates an RxC contingency table.

ASA205, a FORTRAN90 library which generates all the contingency tables corresponding to a given set of row and column sums.

SUBSET, a FORTRAN90 library which includes a routine called IMAT_01_ROWCOLSUM which generates a (0,1) matrix with given row and column sums.

### Author:

Original FORTRAN77 version by James Boyett; FORTRAN90 version by John Burkardt.

### Reference:

1. James Boyett,
Algorithm AS 144: Random R x C Tables with Given Row and Column Totals,
Applied Statistics,
Volume 28, Number 3, 1979, pages 329-332.

### List of Routines:

• I4MAT_PRINT prints an integer matrix.
• I4MAT_PRINT_SOME prints some of an integer matrix.
• I4VEC_PRINT prints an integer vector.
• R8_UNIFORM_01 returns a unit double precision pseudorandom number.
• RCONT generates a random two-way table with given marginal totals.
• TIMESTAMP prints out the current YMDHMS date as a timestamp.

You can go up one level to the FORTRAN90 source codes.

Last revised on 28 January 2008