Understanding the Fisher's exact test calculator — concept and principle
This calculator runs Fisher's exact test on a 2 × 2 table, such as treatment versus control and success versus failure. It gives the two-sided and one-sided p-values, the probability of the observed table, the sample odds ratio and the proportions in each group. Use it when counts are small and the chi-square test is unreliable.
How it is calculated
With row totals R₁ = a + b, R₂ = c + d, column totals C₁ = a + c, C₂ = b + d and total N fixed:
P(table) = R₁! R₂! C₁! C₂! ÷ (N! a! b! c! d!) (hypergeometric probability)
- Every table with the same totals is listed; a runs from max(0, C₁ − R₂) to min(R₁, C₁).
- Two-sided p = sum of the probabilities of all tables no more likely than the observed one.
- One-sided p-values add the tables with a as small, or as large, as observed.
- Sample odds ratio = (a·d) ÷ (b·c).
The principle
If group and outcome are unrelated, then given the totals, which of the yes outcomes fall into group 1 is like drawing cards from a deck without replacement. The hypergeometric formula gives the exact chance of each possible split. The p-value adds up how likely the observed split, or a more extreme one, would be by chance alone. Because it uses exact probabilities instead of a large-sample approximation, it stays valid for small counts.
Worked example
Default inputs: group 1: 9 yes, 3 no; group 2: 2 yes, 8 no.
- Proportions yes: 9 ÷ 12 = 75 % and 2 ÷ 10 = 20 %; total N = 22.
- Probability of this exact table = 0.01403.
- One-sided p (a this large or larger) = 0.01499; one-sided p (a this small or smaller) = 0.999.
- Two-sided p = 0.02997: significant (p ≤ 0.05).
- Sample odds ratio = (9 × 8) ÷ (3 × 2) = 12.
| Group 2 · outcome no (d) | Two-sided p-value |
|---|---|
| 2 | 0.5467 |
| 4 | 0.1414 |
| 6 | 0.06478 |
| 8 | 0.02997 |
| 10 | 0.01228 |
| 12 | 0.004314 |
| 16 | 0.001221 |
How to read the result
A two-sided p of about 0.03 means that, if there were no real difference, a split at least this uneven would happen about 3 times in 100. The odds ratio of 12 shows the size of the difference: the odds of yes are 12 times higher in group 1. With such small groups the estimate is very uncertain, so report a confidence interval as well.
Common mistakes
- Using the chi-square test when expected counts are below 5.
- Choosing a one-sided test after seeing which way the data go.
- Reading a non-significant p as proof of no difference.
- Mixing up rows and columns, which changes the odds ratio's meaning.
Frequently asked questions
When should I use Fisher's exact test?
For 2 × 2 tables with small expected counts, typically below 5 in some cell.
What is the difference between one- and two-sided p?
One-sided tests a difference in a stated direction; two-sided counts extreme tables in either direction.
What does an odds ratio of 12 mean?
The odds of the outcome are 12 times higher in group 1 than in group 2.
Sources: A. Agresti (2013), Categorical Data Analysis, 3rd ed., Wiley (Fisher's exact test for 2 × 2 tables) · R. A. Fisher (1935), The Design of Experiments, Oliver & Boyd