Fisher’s Exact Test Calculator
Type the four counts of a 2 × 2 table to get the exact p-value from every table…
Type the four counts of a 2 × 2 table to get the exact p-value from every table with the same totals, the right test when counts are small.
Paste a table from a spreadsheet
Copy cells from Excel, Google Sheets or a CSV file and paste them here; the grid above follows.
More optionsTwo-sided
ExampleP-value, two-sided
0.0286
Of every table with these row and column totals, the ones at least as extreme as yours add up to 0.0286. Significant at the 5% level (p < 0.05).
Type your own counts, or paste a table.
Each bar is one possible top-left count, with every total kept as it is, and its chance if rows and columns were unrelated (the hypergeometric distribution). The lit bars make up the p-value.
- Odds ratio (ad ÷ bc)
- ∞
- One-sided p (less · greater)
- 1 − 2.00 × 10⁻¹⁵ · 0.0143
- Possible tables
- 5
How this works: 9 sources,
How this works
Method
Fisher’s exact test is for a 2 × 2 table when the counts are small: a few patients per treatment, a handful of defects, a tasting trial. It gives an exact p-value instead of the chi-square approximation, which breaks down when expected counts fall under 5. Full method
Sources
- Wikipedia, Fisher’s exact test
- Wikipedia, Lady tasting tea (Fisher, The Design of Experiments, 1935)
- NIST/SEMATECH e-Handbook of Statistical Methods
- Abramowitz and Stegun, Handbook of Mathematical Functions, chapters 6, 7 and 26 (1964)
- SciPy 1.18 scipy.stats (reference values for the tests)
- statsmodels 0.15 (reference values for the A/B test and regression intervals)
- Welch, The generalization of Student’s problem when several different population variances are involved (Biometrika) (1947)
- Fleiss, Levin and Paik, Statistical Methods for Rates and Proportions, 3rd edition (sample size for two proportions) (2003)
- Hyndman and Fan, Sample quantiles in statistical packages (The American Statistician) (1996)
How it’s tested
2 worked examples for this page are checked by automated tests before every release: given the inputs, the tool must show the expected answer.
Privacy
On your device. Nothing you enter or open leaves this browser. About privacy labels
Changes
- First published: live curves with draggable cut-offs, and tests on pasted data (t-tests, ANOVA, chi-square, Fisher’s exact, correlation, regression, A/B), checked against SciPy.
How Fisher’s exact test works
Fisher’s exact test is for a 2 × 2 table when the counts are small: a few patients per treatment, a handful of defects, a tasting trial. It gives an exact p-value instead of the chi-square approximation, which breaks down when expected counts fall under 5.
The example is Fisher’s own. A colleague, Muriel Bristol, said she could tell whether the milk or the tea had gone into the cup first. Fisher proposed eight cups, four of each, served in random order; she must pick the four milk-first cups. If she were guessing, every set of four is equally likely: there are 70 of them, and only one gets all four right. So a perfect score has a one-sided p-value of 1/70 = 0.014, and the two-sided test, which also counts getting all four wrong, gives 2/70 = 0.029.
In general the test fixes the row and column totals and lists every table that has them. Its top-left count decides the rest, and each possible count has a hypergeometric probability. The two-sided p-value adds the probabilities of every table no more likely than yours; one-sided p-values add one tail. The odds ratio ad ÷ bc says how much the odds differ between the rows.
P(a) = C(a + c, a) × C(b + d, b) ÷ C(N, a + b)
- Fisher’s exact test computes the exact probability of the observed table, and of more extreme ones, from the hypergeometric distribution with the margins fixed. Source: Wikipedia, Fisher’s exact test.
- Fisher described the tea-tasting experiment in The Design of Experiments (1935): with eight cups, four of each kind, there are 70 ways to choose four, so a perfect guess by chance has probability 1/70. Source: Wikipedia, Lady tasting tea (Fisher, The Design of Experiments, 1935).
The tea-tasting test: every possible score
Eight cups, four with milk first. For each number of milk-first cups picked correctly: the number of ways, its probability under guessing, and the one-sided p-value for doing at least that well.
| Correct of 4 | Ways | Probability | P(at least this many) |
|---|---|---|---|
| 0 | 1 | 1/70 = 0.0143 | 1 |
| 1 | 16 | 16/70 = 0.2286 | 0.9857 |
| 2 | 36 | 36/70 = 0.5143 | 0.7571 |
| 3 | 16 | 16/70 = 0.2286 | 0.2429 |
| 4 | 1 | 1/70 = 0.0143 | 0.0143 |
Common questions
When should I use Fisher’s test instead of chi-square?
When the table is 2 × 2 and any expected count is under 5, or the total is small. With large counts the two agree closely and either is fine.
Why are there two one-sided p-values?
“Less” asks whether the top-left count is smaller than chance would give (odds ratio below 1), “greater” whether it is larger. Pick the direction before seeing the data; otherwise use the two-sided p-value.
Why does the odds ratio show ∞?
When b or c is zero, ad ÷ bc divides by zero. It means one row never had one of the outcomes; the p-value is still valid.