The IMSL_EXACT_ENUM function computes exact probabilities in a two-way contingency table using the total enumeration method.

The IMSL_EXACT_ENUM function computes exact probabilities for an N_rows by N_columns contingency table for fixed row and column marginals. A marginal is the number of counts in a row or column.

Let fij denote the count in row i and column j of a table, and let fi• and f•j denote the row and column marginals. Under the hypothesis of independence, the (conditional) probability of the fixed marginals of the observed table is given by: Where:

f•• is the total number of counts in the table

Pf corresponds to the output keyword PROB_TABLE.

A more extreme table X is defined in the probabilistic sense as more extreme than the observed table if the conditional probability computed for table X (for the same marginal sums) is less than the conditional probability computed for the observed table. Note that this definition can be considered "two-sided" in the cell counts.

Because IMSL_EXACT_ENUM uses total enumeration in computing the probability of a more extreme table, the amount of computer time required increases very rapidly with the size of the table. Tables with a large total count f•• or a large value of r by c should not be analyzed using IMSL_EXACT_ENUM. In such cases, try using IMSL_EXACT_NETWORK.

## Example

In this example, the exact conditional probability for the 2 by 2 contingency table is computed as follows: `table = [[8, 8], [12, 2]]`
`p = IMSL_EXACT_ENUM(table, P_Value=pv, Prob_Table=pt, Error_Chk=ec)`
`PRINT, 'p-value =', p`

IDL prints:

`p-value = 0.0576712`

## Syntax

Result = IMSL_EXACT_ENUM(Table [, /DOUBLE] [, ERROR_CHK=variable] [, P_VALUE=variable] [, PROB_TABLE=variable])

## Return Value

The p-value for independence of rows and columns. The p-value represents the probability of a more extreme table where "extreme" is taken in the Neyman-Pearson sense. The p-value is "two-sided."

## Arguments

### Table

Two-dimensional array containing the observed counts in the contingency table.

## Keywords

### DOUBLE (optional)

If present and nonzero, double precision is used.

### ERROR_CHK (optional)

Named variable containing the sum of the probabilities of all tables with the same marginal totals. It should always have a value of 1.0. Deviation from 1.0 indicates a numerical error.

### P_VALUE (optional)

Named variable into which the p-value for independence of rows and columns is stored. The p-value represents the probability of a more extreme table where "extreme" is taken in the Neyman-Pearson sense. The p-value is "two-sided." The p-value is also returned in functional form.

A table is more extreme if its probability (for fixed marginals) is less than or equal to PROB_TABLE.

### PROB_TABLE (optional)

Named variable containing the probability of the observed table occurring, given that the null hypothesis of independent rows and columns is true.

## Version History

 6.4 Introduced