StatGardenREF. DESK
Calculators/Statistics/Fisher's exact test
Statistics

Fisher's exact test calculator

Runs a two-tailed Fisher exact test on a 2×2 contingency table of counts.

Published 9 August 2026 · Updated 25 September 2026

What this calculator does

Fisher exact test computes the probability of a 2x2 table directly rather than approximating it, which makes it the correct choice when counts are small. A table of 8, 2, 1, 9 gives a two-tailed p-value of 0.005477 and an odds ratio of 36.

Exact here means literally exact. The test enumerates every possible table with the same row and column totals, computes the probability of each, and sums those no more likely than the one observed. There is no approximation to break down, which is why it remains valid where a chi-square test does not.

The formula

FormulaP(table) = (a+b)!(c+d)!(a+c)!(b+d)! / (a!b!c!d!n!). Two-tailed p-value sums P over all tables (same margins) with P ≤ P(observed)

The probability of any particular table with fixed margins follows the hypergeometric distribution. The two-tailed p-value sums the probabilities of all tables at least as extreme as the observed one, meaning all those whose individual probability is no greater. The margins are treated as fixed, which is the assumption that makes the enumeration possible.

TermMeaning
Exact testOne computing the probability directly rather than via an approximating distribution.
Odds ratioad/bc, the ratio of odds between the two rows.
Fixed marginsRow and column totals held constant, which defines the set of tables enumerated.
HypergeometricThe distribution giving the probability of each table with those margins.

The inputs explained

FieldWhat to enter
Group 1, outcome AGroup 1, outcome A count.
Group 1, outcome BGroup 1, outcome B count.
Group 2, outcome AGroup 2, outcome A count.
Group 2, outcome BGroup 2, outcome B count.

When to use it

Small sample 2x2 comparisons

Where any expected count falls below 5, chi-square is unreliable and Fisher is correct.

Rare outcome studies

A rare event produces small cells regardless of how large the overall sample is.

Laboratory comparisons

Experiments with few replicates per condition routinely produce tables too small for chi-square.

Worked examples

Every figure in the tables below is produced by this page’s own calculator at build time, so the numbers and the tool always agree. Select any row to load that scenario.

How does the table affect the p-value?

A range of group 1 splits against the same comparison group.

Group 2 fixed at 1 and 9
Group 1, outcome A (b = 2)Two-tailed p-valueOdds ratio (a·d)/(b·c)Probability of observed table
a = 10.4230774.5000.384615
a = 50.03450222.5000.016968
a = 80.00547736.0000.002679
a = 90.00190540.5000.001559
Because b stays at 2, raising a grows group 1 rather than shifting its split, so the totals change down the table. The a = 1 row leaves both groups at similar rates and is nowhere near significant at p = 0.423077. By a = 9 the odds ratio reaches 40.5 and p falls to 0.001905.

Questions

When should I use Fisher instead of chi-square?

When any expected cell count falls below about 5, which is the standard guideline. Fisher is valid at any sample size, so using it always is defensible, though for large tables it is computationally heavier and gives essentially the same answer.

Is Fisher’s test conservative?

Yes, somewhat, because it conditions on the observed margins which are not genuinely fixed in most study designs. This makes the actual error rate lower than the nominal level, so the test is less likely to detect a real effect than the stated alpha suggests.

What does the odds ratio tell me?

How many times higher the odds of the outcome are in one group than the other. An odds ratio of 36 means the odds are 36 times greater. It is not a risk ratio, and the two diverge substantially when the outcome is common.

Why is the two-tailed p-value not just double the one-tailed?

Because the hypergeometric distribution is asymmetric, so the two tails are not mirror images. The convention used here sums the probabilities of all tables no more likely than the observed one, which is the most common definition but not the only one in use.

For larger tables, see the chi-square goodness of fit calculator. For paired binary data, see the McNemar’s test calculator.