A little context. A clearer answer.
When this calculator is useful
Enumerate all admissible upper-left counts with the observed row and column totals. Compute normalized hypergeometric log probabilities to avoid factorial overflow. Sum the appropriate tail or probability-ordered set. Very small p-values use scientific or logarithmic notation. For a related calculation, try Hypergeometric probability calculator.
What to enter
| Input | What it means | Example value |
|---|---|---|
| a (1,1) | Count in the first row and first column of the contingency table. a (1,1): 0…5000 | 6 |
| b (1,2) | Count in the first row and second column. b (1,2): 0…5000 | 2 |
| c (2,1) | Count in the second row and first column. c (2,1): 0…5000 | 1 |
| d (2,2) | Count in the second row and second column. d (2,2): 0…5000 | 4 |
| Mode | Mode: Two-sided / Less / Greater | Two-sided |
How the calculation works
- Change the inputs to explore your own scenario. a (1,1): 0…5000 ; b (1,2): 0…5000 ; c (2,1): 0…5000 ; d (2,2): 0…5000 ; Mode: Two-sided / Less / Greater.
- P(X=x)=C(a+c,x)C(b+d,a+b−x)/C(n,a+b); p₂=Σ{P(x):P(x)≤P(a)}
- Independent observations in a 2×2 count table, conditional on fixed margins. Two-sided means summing tables no more probable than the observed table; it is not automatically twice a one-sided p-value. Sample odds ratio is ad/bc; it can be undefined or infinite. No confidence interval or causal conclusion.
P(X=x)=C(a+c,x)C(b+d,a+b−x)/C(n,a+b); p₂=Σ{P(x):P(x)≤P(a)}A worked example
For [[6,2],[1,4]], sample OR=12; two-sided p=0.1025641025641, greater p=0.0862470862471 and less p=0.995337995338.
Example you can load
What to enterThis is a fixed example; changing the form above does not change these numbers.
Assumptions & limits
Independent observations in a 2×2 count table, conditional on fixed margins. Two-sided means summing tables no more probable than the observed table; it is not automatically twice a one-sided p-value. Sample odds ratio is ad/bc; it can be undefined or infinite. No confidence interval or causal conclusion.
Frequently asked questions
What counts can I enter?
Nonnegative integer counts, not percentages, weights or paired measurements. At least one observation is required; each cell is limited to 5000.
Why is two-sided p different from twice one tail?
The supported definition includes all fixed-margin tables whose probability is no greater than the observed table’s probability. Discrete asymmetric distributions need not give twice a tail.
Which odds ratio is shown?
The sample cross-product ratio ad/bc, without adding a continuity correction. It is not the conditional maximum-likelihood estimate.