Fisher Exact Test Calculator
Enter four counts and get Fisher's exact p-value — two-sided by probability ordering, the way R computes it — with both odds ratios, the Cornfield exact confidence interval, expected counts and an APA-ready sentence. This Fisher exact test calculator enumerates every table with your margins, in your browser; nothing is uploaded.
Table 1. The 2 × 2 calculator. Type your counts; the row and column margins are held fixed, exactly as Fisher's test requires. Labels can be renamed.
Your 2×2 table
| Total | |||
|---|---|---|---|
| 10 | |||
| 6 | |||
| Total | 9 | 7 | 16 |
Zero cells: if a cell is zero, the sample odds ratio is 0 or infinite. This calculator says so in words; it never adds a silent 0.5 correction to make the number finite.
Four numbers in reading order fill a, b, c, d. Pasting a block into any cell fills the grid too.
Options — alternative, significance level, confidence level, mid-p
Two-sided is the standard choice; pick a side only if the direction was decided before seeing the data.
The drug-trial table is a constructed teaching example, pre-filled so the result block has real figures to explain. The tea and NIST tables are the cited classics.
No test exists for this table
A whole row or column is zero, so exactly one table has these margins and there is nothing to compare. Fisher's exact test is undefined for a zero-margin table, so no p-value is printed — there is no result to print.
Result — Fisher's exact test
—
- P(observed table)probability of exactly this table under the null
- —
- One-sided p (greater)tables with a top-left cell at least the observed
- —
- One-sided p (less)tables with a top-left cell at most the observed
- —
- Two-sided mid-pmid-p (less conservative) — never the headline figure
- —
- One-sided mid-p (greater)mid-p (less conservative) — never the headline figure
- —
- One-sided mid-p (less)mid-p (less conservative) — never the headline figure
- —
- Sample odds ratioad / bc — the odds ratio of this table itself
- —
- Conditional-MLE odds ratiothe estimate R's fisher.test reports
- —
- Cornfield's exact interval, attached to the conditional-MLE estimate
- —
- Woolf logit intervalan approximation — shown only for comparison
- —
The same table through the approximations
- Pearson chi-square p
- —
- Chi-square p, Yates correction
- —
- G-test p
- —
| — | — |
| — | — |
Report it (APA)
The OR is the conditional-MLE estimate and the interval is the exact (Cornfield) interval — the pairing R's fisher.test reports. A following note names the two-sided definition: probability ordering.
The same table in your software
R
Python (SciPy)
SPSS
Analyze → Descriptive Statistics → Crosstabs → Exact… → Exact (requires the Exact Tests module). The two-sided p SPSS prints uses the same probability-ordering definition.
Excel
| Top-left cell x | Table | P(x) | Counted in two-sided p |
|---|---|---|---|
| Sum of all probabilities | — |
Your counts never leave your browser — the calculation runs on this page, and the share link encodes the table in the URL itself.
Your result explained
The headline number is the p-value for the alternative you selected — two-sided unless you changed it. Read it against your significance level: at the default α = 0.05, a p-value of 0.0350 is conventionally called statistically significant, meaning tables this uneven would arise under the null hypothesis of no association in about 3.5% of repeated experiments with the same margins. The panel separates what other calculators often merge: the probability of your exact table, both one-sided p-values, the sample odds ratio computed straight from your counts, the conditional maximum-likelihood estimate that R reports, and the Cornfield exact confidence interval. The expected counts and the Cochran line tell you whether a chi-square approximation would have been defensible for the same data.
What is Fisher's exact test?
Fisher's exact test answers a narrow question about a 2×2 table: if there were truly no association between the row variable and the column variable, how surprising is the table you observed — counting not just this table but every table with the same row and column totals that is at least as unlikely? It is called exact because the probability is computed by enumerating those tables directly, not by approximating a sampling distribution. R. A. Fisher introduced the test in the 1930s; it remains the reference method for categorical data with small counts and for any 2×2 table where an approximation cannot be trusted.
The lady tasting tea
The test's founding example is disarmingly small. Muriel Bristol, a colleague of Fisher's at Rothamsted, claimed she could tell whether milk had been poured into a cup before or after the tea. Fisher prepared eight cups — four milk-first, four tea-first — and Bristol identified all four of one kind correctly. Under the null hypothesis of guessing, the probability of a perfect classification is 1 in 70, about 0.0143 one-sided; the two-sided value for her table [[4, 0], [0, 4]] is 0.0286. Try it: the lady tasting tea preset above loads her table, and the calculator shows the infinite odds ratio a perfect score produces.
Why fixed margins give a hypergeometric null
Fix the margins and a 2×2 table has only one degree of freedom: choose the top-left cell and the other three are determined. Under the null hypothesis, that cell follows the hypergeometric distribution — the same distribution that governs drawing balls from an urn without replacement. If the column totals say 9 of 16 subjects improved, then under no association the number of improvers landing in a row of 10 is exactly the number of successes in 10 draws from an urn holding 9 improvers and 7 non-improvers. Fisher's test is nothing more — and nothing less — than adding up the right set of that distribution.
When to use it — the expected-count rule
Reach for Fisher's exact test when the counts are small enough that an approximation's error matters — the working rule, due to Cochran, is that the chi-square approximation becomes unreliable when expected counts fall below 5 in a substantial share of cells. The calculator prints the expected counts and the Cochran verdict for your table, so the choice is evidence-based rather than habitual. Try the checker with your own counts:
The formula, with a worked example
With row totals R₁ and R₂, first-column total C₁, and grand total N, the probability of the table whose top-left cell equals x is the hypergeometric mass below. The worked example that follows it is computed live by the same engine as the calculator, so its figures can never drift from the tool's.
Hypergeometric probability of one table with fixed margins
P(x) = C(R₁, x) · C(R₂, C₁ − x) / C(N, C₁)
Equivalently, with the four cell counts a, b, c, d: P = (R₁! R₂! C₁! C₂!) / (a! b! c! d! N!). Your observed table contributes one such term; the p-values are sums of these terms over the tables the chosen alternative counts. The formula needs factorials of the margins only — no estimated parameters, no degrees of freedom, and no continuity correction, which is precisely why the result is exact rather than approximate.
How the p-value is computed — every table with your margins
The calculator enumerates every table that shares your margins. For the default table there are seven: the top-left cell can range from 3 to 9, and each candidate table's probability comes from the formula above. The observed table (x = 8) has probability 0.023601. The one-sided p-value for 'greater' adds the probabilities of the observed table and every table more extreme in that direction (x = 9): 0.024476. The one-sided 'less' value adds everything down to x = 3: 0.999126 — large because the observed table sits near the top of the range.
The enumeration table
Figure 1 in the calculator lists all seven tables with their probabilities; the bars make the shape of the null distribution visible. The probabilities sum to exactly 1, which is the internal check that the enumeration is complete. Tables counted toward the two-sided p-value are marked — for the default table they are x = 3, 8 and 9, the tables whose probability does not exceed the observed table's 0.023601.
One-sided vs two-sided — and why two-sided is not double the one-sided
A one-sided test asks about one direction only: is the odds ratio greater than 1, or less than 1? A two-sided test asks whether the table is surprising in either direction, and Fisher's definition — the one R uses — counts every table whose probability is at most the observed table's probability. That is not the same as doubling the smaller one-sided value. Doubling would give 0.0490 for the default table; probability ordering gives 0.0350, because the hypergeometric distribution here is asymmetric — the far tail contributes one small table (x = 3, probability 0.010490) rather than a mirror image of the near tail. Choose the alternative before looking at the data; switching afterwards to whichever value is smaller is a quiet form of p-hacking.
Fisher vs chi-square
For the default table the approximations scatter around the exact answer: Pearson's chi-square gives p = 0.0134, the G-test 0.0107, and Yates' continuity-corrected chi-square 0.0510 — one of them even crosses the 0.05 line in the opposite direction from the others. The exact two-sided value is 0.0350. The approximations improve as counts grow and are perfectly serviceable for large tables, but they estimate a probability that Fisher's test computes outright. When expected counts are small, or when a result sits near a decision boundary, the exact figure is the one to report — with the approximation, if you show it at all, labelled as an approximation.
The odds ratio — sample vs conditional MLE, and the exact CI
The p-value says how surprising the table is; the odds ratio says how strong the association is. The sample odds ratio is the cross-product of your counts, ad/bc — 20.00 for the default table, where the odds of improvement were 8:2 on treatment against 1:5 on control. R's fisher.test reports a different number, the conditional maximum-likelihood estimate (15.47 here): the odds ratio under which the observed table is the most likely outcome, given the margins. Neither is wrong; they estimate the same quantity by different routes, and this calculator shows both, labelled, rather than silently picking one. The Cornfield interval is the exact companion to the test: the set of odds ratios not rejected at your confidence level. Its width is the honest price of small samples — [1.009, 1059.6] barely excludes 1, which is exactly what p = 0.0350 says in another language.
Larger tables — the Freeman–Halton extension
The same enumeration extends to r×c tables — the Freeman–Halton extension — but the number of tables with given margins explodes combinatorially, and beyond modest sizes exact enumeration gives way to network algorithms or Monte Carlo simulation of the p-value. This calculator is deliberately a 2×2 instrument: it enumerates completely, instantly, and verifiably. For larger tables, run the same probability-ordering definition in R with fisher.test on an r×c matrix (adding simulate.p.value = TRUE when enumeration runs out of memory), and report that the value is simulated, with the number of replicates, when it is.
Why calculators disagree
Two calculators fed the same table can honestly print different p-values, because 'Fisher's exact test' names a family of conventions, not one number. The largest gap is the two-sided definition: probability ordering, as used by R and by this calculator, gives 0.0350 for the default table, while doubling the one-sided value gives 0.0490 — a difference that straddles many a significance threshold. Next, some tools quietly report the mid-p value, which halves the observed table's contribution and is systematically smaller. Others default to a one-sided alternative, or apply a continuity correction that belongs to the chi-square family, not to Fisher's test. The odds ratio causes a second, quieter disagreement: the sample cross-product (20.00) versus the conditional MLE (15.47). And intervals differ too — the Woolf logit interval is a normal approximation, while the Cornfield interval is exact. When a number matters, ask which conventions produced it; this page labels every one of its own.
Assumptions & when NOT to use it
- Independent observations: each subject contributes to exactly one cell. Paired or repeated measurements need a paired test (McNemar), not Fisher's.
- Categorical counts: the data are frequencies in a 2×2 classification — not means, percentages, or measurements.
- Fixed margins by design or by conditioning: the test conditions on the observed row and column totals; it is valid whether or not the margins were fixed in advance, but the interpretation is conditional on them.
- No minimum sample size: exactness does not require large counts — small samples cost power, not validity.
How to report it
Report the test, the alternative, the exact p-value, an effect size, and the interval — the APA sentence in the result panel is a complete template, and the routes below reproduce this calculator's two-sided p-value for the default table in R, Python, SPSS and Excel. Name the software and the two-sided convention in your methods section; 'Fisher's exact test, two-sided by probability ordering' is one unambiguous line.
Common mistakes
- Doubling the one-sided p-value and calling it two-sided Fisher — the two-sided value is a sum over tables, not a multiple.
- Reading the sample odds ratio and R's conditional estimate as a contradiction — they are two estimators of one quantity; report which one you used.
- Calling the Woolf (logit) interval 'the exact CI' — it is a normal approximation; the Cornfield interval is the exact one.
- Switching to a one-sided alternative after seeing the data — the direction must be fixed before the counts are known.
- Reporting p = 0.035 as 'a 3.5% chance the null is true' — the p-value is the probability of tables this extreme given the null, not the probability of the null given the table.
Frequently asked questions
What is Fisher's exact test used for?
When should I use Fisher's exact test instead of chi-square?
How do I calculate Fisher's exact test by hand?
What is the difference between one-tailed and two-tailed Fisher's exact test?
How do I interpret a Fisher's exact test p-value?
Can Fisher's exact test be used for tables larger than 2×2?
Does Excel have a Fisher's exact test function?
Why do two calculators give different two-sided p-values for Fisher's exact test?
Is Fisher's exact test one-sided or two-sided by default?
How do I report Fisher's exact test in APA style?
What does an odds ratio of 2 mean?
What does 'exact' mean in Fisher's exact test?
What if one of my cells is zero?
Why is the confidence interval so wide?
Why is the odds ratio here different from the one R gives me?
Is the two-sided p-value just double the one-sided p-value?
Can I enter percentages instead of counts?
Is my data uploaded anywhere?
Related calculators
The rest of the exact-test family: larger tables, the odds ratio on its own, the full 2×2 battery, chi-square, and McNemar for paired data.
Sources & method notes
Fisher, R. A. (1935). The Design of Experiments. Edinburgh: Oliver & Boyd — the lady tasting tea appears in Chapter II. Salsburg, D. (2001). The Lady Tasting Tea. New York: W. H. Freeman. Cornfield, J. (1956). A statistical problem arising from retrospective studies. Proceedings of the Third Berkeley Symposium, 4, 135–148. Cochran, W. G. (1954). Some methods for strengthening the common χ² tests. Biometrics, 10(4), 417–451. NIST/SEMATECH e-Handbook of Statistical Methods, §7.3.5 (worked example 3). This calculator's engine was cross-checked against SciPy's fisher_exact and an independent exact enumeration.