Bell Statistics

What is Fisher's exact test?

Fisher's exact test compares proportions in a small table by enumerating every arrangement of the data that keeps the row and column totals fixed. Because it computes the probability directly rather than approximating it, sparse counts do not distort the answer.

Also called
fisher exact test, fisher-irwin test, exact test for small counts
Allon Korem

Written by Allon Korem

Chief Executive Officer

Last updated

In plain English

A chi-square test does not compute the probability of your table. It computes a statistic and compares it against a continuous curve that the statistic only approximately follows — an approximation that is excellent when the counts are large and poor when they are not. Fisher's exact test skips the approximation. It asks directly: holding the row and column totals fixed, how many possible tables are at least as extreme as the one I observed, and what fraction of the total do they represent?

The mechanism is combinatorial rather than distributional. With the margins fixed, a 2 × 2 table has exactly one free cell, so every possible outcome can be listed and its probability computed from the hypergeometric distribution. Sum the probabilities of the tables as extreme or more extreme than yours and that sum is the p-value. Nothing is estimated and nothing is approximated, which is where the word "exact" comes from — it describes the computation rather than any claim to superior accuracy about the world.

That is why it is the standard answer when a cell expects fewer than five. Below that threshold the chi-square approximation misbehaves in the dangerous direction — it tends to return p-values that are too small, so a false positive is more likely than the number claims. A test with 90,000 users and eleven conversions between the arms is precisely this situation, and it happens far more often than the raw sample size suggests, because rare events stay rare no matter how much traffic you pour in.

It has two real costs. The first is computational: enumeration grows quickly with table size, which is why it is routine for 2 × 2 and unusual for anything much larger. The second is that it is conservative. Conditioning on the margins — treating both sets of totals as fixed when in reality only one was — means the achievable p-values come in discrete jumps, and the test's actual false-positive rate sits below the nominal 5% rather than at it. You are trading some power for a guarantee that the rate is never exceeded.

In an experimentation context the practical rule is simple. Check the smallest expected count before choosing: at five or above use chi-square or a z-test and enjoy the extra power; below it use Fisher's and accept the conservatism. What you must not do is run both and report whichever crossed the threshold, which converts a principled choice into a multiple comparisons problem with a sample size of one.

The formula

One hypergeometric probability per possible table, summed over the tables at least as extreme as the observed one. There is no test statistic in the usual sense.

Probability of one table
P = ( a+b C a )( c+d C c ) / ( n C a+c )

For a 2 × 2 table with cells a, b, c, d. Read directly off the hypergeometric distribution with the margins held fixed.

The p-value
p = Σ P(table) over all tables at least as extreme as observed

A sum over enumerated possibilities rather than a tail area under a curve — see the Fisher's exact calculator.

Degrees of freedom in a 2 × 2 table
df = ( 2 − 1 )( 2 − 1 ) = 1

One free cell once the margins are fixed, which is exactly what makes full enumeration tractable — see degrees of freedom.

When to prefer it
min( expected cell count ) < 5

Expected, not observed. A cell can legitimately observe zero while expecting twenty, and that is a finding rather than a problem.

Worked example

An enterprise onboarding test runs on a small population: 48 accounts in control and 46 in the variant. Control produced 2 activations, the variant 8. That is 4.2% against 17.4%, a fourfold difference, and the team wants to know whether 94 accounts can support the claim.

Control
2 activated / 48 (4.2%)
Variant
8 activated / 46 (17.4%)
Smallest expected count
10 × 48 / 94 = 5.1 activations in control
Chi-square (uncorrected)
χ² = 4.29, p = 0.038
Chi-square with Yates
χ² = 2.98, p = 0.084
Fisher's exact
p = 0.049, two-sided

Three tests on one table give 0.038, 0.084 and 0.049 — two on one side of the conventional threshold and one on the other.

The spread across those three numbers is the real lesson. This table sits right on the boundary where the approximation starts to matter: the smallest expected count is 5.1, barely clearing the rule of thumb, and the three methods disagree by more than the width of the decision. Anyone free to pick among them can produce whichever verdict they prefer, which is why the choice has to be made before the data is seen. Fisher's is the defensible default here, and its p = 0.049 should be read as what it is — a result that has cleared a line by a hair on ten activations in total. The honest summary is that the variant looks considerably better and 94 accounts cannot establish by how much: the confidence interval on the difference runs from roughly 1 to 27 percentage points.

Common misconceptions

"Exact" means Fisher's test is more accurate than the alternatives.
It means the p-value is computed by direct enumeration rather than by approximating a distribution. That is a statement about the arithmetic, not about being closer to the truth. Because the test conditions on both margins it is in fact conservative — its real false-positive rate sits below the nominal level, so it errs towards missing effects rather than inventing them.
Fisher's exact test is only for tiny samples.
It is for tiny expected COUNTS, which can occur at any sample size. An experiment with 200,000 users and a 0.002% conversion rate has four conversions and needs it; a 400-user test with a 40% conversion rate does not. The trigger is the sparsest cell, not the number of rows in the dataset.
If chi-square and Fisher's disagree, report the one that reached significance.
That is a multiple comparisons problem disguised as a methodological choice, and it doubles your error rate without appearing anywhere in the output. Pick the test from the expected counts before looking at the result. When they disagree the honest reading is that the data is too thin to settle the question either way.

Frequently asked questions

Can Fisher's exact test handle tables bigger than 2 by 2?
In principle yes, and most modern software will do it, but the enumeration grows very quickly with table size and it becomes slow or infeasible beyond modest dimensions. For larger sparse tables the practical alternatives are a Monte Carlo approximation to the exact p-value, which most packages offer, or combining thin categories into meaningful groups before testing — the second is usually better statistics as well as faster.
Why is Fisher's exact test described as conservative?
Because it conditions on both sets of margins as though they were fixed in advance, when in reality only the group sizes usually were. That restriction means only a discrete set of p-values is attainable, and the test's true false-positive rate lands below the nominal 5% rather than at it. The practical consequence is a modest loss of power: some real effects go undetected in exchange for never exceeding the stated error rate.
How do I get a confidence interval to go with Fisher's exact test?
Use the conditional maximum likelihood interval for the odds ratio, which most implementations return alongside the p-value, or a bootstrap interval on the difference in proportions if you want the answer in percentage points. Reporting an interval matters more here than usual: the tests that need Fisher's are the ones with the least data, so the plausible range is wide and a bare p-value hides exactly how uncertain the estimate is.

Related terms

  • Chi-square test

    The test for counts in a table — the standard SRM check, and the reason expected counts matter more than sample size.

  • Log-rank test

    For questions about when rather than whether — and it uses the people who have not converted yet instead of discarding them.

  • McNemar's test

    The paired test for yes-or-no outcomes — and it throws away every subject who did not change their mind.

  • Z-test

    The test behind every conversion-rate readout — and the one condition that decides whether it is safe to use.

Calculate it

  • Fisher's exact test

    The right test for a 2×2 table of small counts — exact p-values, no normal approximation.

  • Chi-square test

    Test a contingency table of counts for association — any number of rows and columns.

Knowing the term is the easy part

Applying it to a live measurement problem is the part that goes wrong. If you are designing an experiment, reading a result you do not trust, or trying to work out what your marketing actually caused, that is the work we do.