Fisher's Exact Test Calculator

Enter your 2×2 contingency table to get Fisher's exact p-value, odds ratio, and confidence interval.

F Fisher's Exact Test Calculator

Enter the four cells of your 2×2 contingency table.

Outcome: YesOutcome: No
Group 1
Group 2

p-Values

Two-tailed p-value
-
One-tailed p (left)
-
One-tailed p (right)
-

Effect Size

Odds Ratio (OR)
-
Relative Risk (RR)
-
95% CI for OR (Woolf)
-
Total n
-

📖 What is Fisher's Exact Test?

Fisher's exact test is a statistical significance test used to determine whether there is a non-random association between two categorical variables in a 2×2 contingency table. Unlike the chi-square test, which uses an approximation to the chi-square distribution, Fisher's test computes the exact probability of the observed table (and all tables more extreme) using the hypergeometric distribution. This makes it valid for any sample size, including very small samples where the chi-square approximation breaks down.

The test was developed by Ronald Fisher in 1922 and is famous for the "Lady Tasting Tea" experiment, where Fisher devised the test to evaluate whether a woman could truly distinguish whether milk or tea was poured first into a cup. The lady was presented with 8 cups - 4 with milk first, 4 with tea first - and asked to identify each. Fisher's exact test computed the probability that she could have achieved her observed score purely by chance.

The p-value is computed by summing the hypergeometric probabilities for all 2×2 tables with the same margins (row and column totals) that are as or more extreme than the observed table. "More extreme" for the two-tailed test means tables with a probability equal to or less than the observed table's probability. The formula for each table's probability is P = (a+b)!(c+d)!(a+c)!(b+d)! / (a!b!c!d!n!). For numerical stability, this calculator uses log-factorials and exponentiation to avoid overflow.

Beyond the p-value, the odds ratio (OR = ad/bc) measures the strength of association - how many times more likely the outcome is in group 1 vs group 2. The relative risk (RR) is the ratio of probabilities. The Woolf 95% confidence interval for the OR is computed using the log-normal approximation, which is standard for odds ratio estimation in epidemiology and clinical research.

📐 Formulas

P(table) = (a+b)! × (c+d)! × (a+c)! × (b+d)! / (a! × b! × c! × d! × n!)

Two-tailed p-value: Sum P(table) for all tables with P(table) ≤ P(observed).

One-tailed p-value (left): Sum P(table) for all tables with a ≤ observed a.

One-tailed p-value (right): Sum P(table) for all tables with a ≥ observed a.

Odds Ratio: OR = (a × d) / (b × c)

Relative Risk: RR = (a / (a+b)) / (c / (c+d))

Woolf 95% CI for OR: exp(ln(OR) ± 1.96 × √(1/a + 1/b + 1/c + 1/d))

Table notation:

a = Group 1, Outcome Yes | b = Group 1, Outcome No | c = Group 2, Outcome Yes | d = Group 2, Outcome No | n = a+b+c+d

📖 How to Use This Calculator

1
Identify your two groups (rows) and binary outcome (columns). Group 1 might be "treatment", Group 2 "control". Columns might be "recovered" vs "not recovered".
2
Count the subjects in each cell: a = Group 1 & Yes, b = Group 1 & No, c = Group 2 & Yes, d = Group 2 & No. Enter these in the table.
3
Click Calculate. The verdict gives an immediate significance judgement. Review the OR and 95% CI for the effect size and direction.

💡 Example Calculations

Example 1 - Clinical trial: new antibiotic vs placebo

1
Table: Antibiotic group: 12 recovered, 3 not. Placebo group: 4 recovered, 14 not. n = 33. This is a small trial where Fisher's exact test is appropriate.
2
OR = (12×14)/(3×4) = 168/12 = 14.0. The odds of recovery are 14 times higher with the antibiotic than placebo.
3
Two-tailed p = 0.001 - highly significant. 95% CI for OR: 2.3 to 86.2 - wide due to small n but excludes 1 throughout.
4
Conclusion: Strong evidence of a treatment effect even with only 33 patients. The wide CI reflects small sample size - a larger study would narrow the interval.
Result = OR = 14.0, two-tailed p = 0.001 - Highly significant
Try this example →

Example 2 - Genetic association study

1
Table: Cases with allele A: 8, cases without: 12. Controls with allele A: 2, controls without: 18. Testing whether allele A is associated with the disease.
2
OR = (8×18)/(12×2) = 144/24 = 6.0. Allele A confers 6-fold higher odds of disease compared to the reference allele.
3
Two-tailed p = 0.025 - significant at 5%. Expected cell counts: minimum expected count = 20×10/40 = 5, borderline for chi-square. Fisher's exact is the correct choice here.
4
Note: In a full GWAS, this p-value would not survive Bonferroni correction for thousands of SNPs tested - see the Bonferroni Correction Calculator for how to adjust.
Result = OR = 6.0, two-tailed p = 0.025 - Significant at 5%
Try this example →

❓ Frequently Asked Questions

When should I use Fisher's exact test instead of chi-square?+
Use Fisher's exact test when: (1) any expected cell frequency in the 2×2 table is less than 5; (2) the total sample size n is small (typically n < 20–40); (3) you want an exact p-value rather than a chi-square approximation. The chi-square test uses a normal approximation to the chi-square distribution that breaks down with small expected counts. Fisher's exact test computes the exact probability using the hypergeometric distribution and is valid regardless of sample size. For large samples with all expected counts ≥ 5, both tests give nearly identical results.
How do I set up the 2×2 table?+
The standard orientation is: rows = two groups (e.g. treatment vs control, exposed vs unexposed), columns = outcome (e.g. event yes vs no, case vs control). Cell a = group 1 with outcome; cell b = group 1 without outcome; cell c = group 2 with outcome; cell d = group 2 without outcome. For a clinical trial: a = treated patients who recovered, b = treated who did not recover, c = control who recovered, d = control who did not recover. The row and column totals (margins) are treated as fixed in Fisher's exact test.
What does the odds ratio mean?+
The odds ratio (OR) measures the strength of association between the row variable and the column variable. OR = (a × d) / (b × c). An OR of 1 means no association. OR > 1 means the event is more likely in group 1 (row 1). OR < 1 means the event is less likely in group 1. For example, if OR = 3.5, the odds of the outcome are 3.5 times higher in group 1 than group 2. The 95% CI for the OR tells you the precision of this estimate: if the CI excludes 1, the association is statistically significant.
What is relative risk vs odds ratio?+
Relative risk (RR = risk ratio) is the ratio of probabilities: (a/(a+b)) / (c/(c+d)). Odds ratio is the ratio of odds: (a/b) / (c/d). RR is easier to interpret (e.g. 'twice as likely') but cannot be computed from case-control studies where the row or column margins are fixed by design. Odds ratio can always be computed and is the natural measure for logistic regression and case-control studies. When the event is rare (< 10%), OR ≈ RR. For common events, OR overstates the relative risk compared to RR.
What is the hypergeometric distribution and how does Fisher's test use it?+
The hypergeometric distribution gives the probability of drawing exactly k successes in n draws from a population of N items containing K successes, without replacement. In Fisher's exact test, the table margins (row and column totals) are held fixed, and the question is: how many tables are as extreme or more extreme than the observed one? The probability of any 2×2 table with fixed margins is given by the hypergeometric formula P = (a+b)!(c+d)!(a+c)!(b+d)! / (a!b!c!d!n!). The two-tailed p-value is the sum of probabilities for all tables with probability ≤ the observed table's probability.
What does one-tailed vs two-tailed mean in Fisher's exact test?+
In a two-tailed test, you ask: 'Is there any association, in either direction?' The two-tailed p-value is the probability of observing a table as or more extreme than yours in either direction. In a one-tailed test, you ask a directional question before seeing the data: 'Is cell a larger (or smaller) than expected?' The one-tailed p-value is the probability of getting a table as or more extreme in only the specified direction. Use two-tailed for most analyses. One-tailed is appropriate only when you have a strong prior reason to test only one direction and you pre-committed to it before data collection.
What is the Woolf method for the confidence interval of an odds ratio?+
The Woolf method (1955) uses log-transformation to compute the CI for the OR. The log of the OR is approximately normally distributed with variance 1/a + 1/b + 1/c + 1/d. The 95% CI is exp(ln(OR) ± 1.96 × √(1/a + 1/b + 1/c + 1/d)). This method requires all four cells to be non-zero. If any cell is zero, the OR is 0 or infinity and the Woolf CI is undefined - you would need to add a continuity correction (e.g. add 0.5 to each cell) or use exact methods.
Can Fisher's exact test be used for tables larger than 2×2?+
Yes, Fisher's exact test can be extended to r×c contingency tables using the generalized hypergeometric distribution, but the computation becomes very intensive for large tables. For 2×3, 3×3 or larger tables, exact software (like R's fisher.test or StatXact) is typically used. The p-value is computed by summing all table configurations as or less likely than the observed one. For large sparse tables, Monte Carlo simulation is often used to approximate the p-value because complete enumeration is infeasible.