Fisher's Exact Test Calculator
Compute exact two-tailed and one-tailed p-values for 2×2 contingency tables without asymptotic approximation error. Includes full hypergeometric distribution modeling, Cochran's rule check, sample odds ratio, relative risk, and Lancaster's mid-p value.
2 × 2 Contingency Table
Enter observed counts across independent groups
One or more cells have an expected frequency below 5. Pearson's Chi-Square test suffers from substantial asymptotic approximation error here. Fisher's Exact Test is the necessary and authoritative gold-standard.
Fisher's Exact Test is an exact conditional test. By conditioning on the fixed row totals (R₁, R₂) and column totals (C₁, C₂), the degrees of freedom become 1: knowing cell aalone completely determines the entire 2×2 table. Under the null hypothesis of independence, cell a follows a pure Hypergeometric distribution.
Hypergeometric Distribution of Cell a: [min = 0, max = 4]
Each bar is a possible 2×2 table keeping margins fixed. Hover to inspect.
Complete Step-by-Step Mathematical Walkthrough
Calculated with your exact numbers and fixed marginal totals
The exact probability of observing cell a = 3 under H₀ is:
Because the test p-value (0.4857) is greater than or equal to α = 0.05, we fail to reject the null hypothesis. The observed association does not exceed random hypergeometric chance fluctuation at the 5% significance level.
What is Fisher's Exact Test?
Fisher's Exact Test is a non-parametric statistical significance test introduced by Sir Ronald A. Fisher in 1935. It evaluates whether there is a non-random association between two categorical variables in a 2 × 2 contingency table. Unlike Pearson's Chi-Square test—which relies on large-sample asymptotic approximations that require the central limit theorem—Fisher's test calculates the exact mathematical probability of obtaining the observed table (and tables more extreme) under the null hypothesis.
The test is especially indispensable when sample sizes are small, or when any cell in the 2×2 table has an expected frequency of less than 5. It conditions on the marginal totals (the sum of each row and column being fixed), allowing the distribution of cell frequencies to be modeled precisely via the Hypergeometric distribution.
When to Choose Fisher's Exact Test vs. Alternative Tests
Statistical test selection for 2×2 contingency tables depends primarily on sample size and study design:
| Statistical Test | Sample Size Criteria | Subject Pairing | Best Practical Use |
|---|---|---|---|
| Fisher's Exact Test | Small (N < 20 or any E < 5) | Independent groups | Gold standard for rare outcomes, small clinical trials, and cell counts < 5. |
| Pearson's Chi-Square (χ²) | Large (All E ≥ 5) | Independent groups | Standard asymptotic test for large survey and epidemiological datasets. |
| Yates' Continuity Corrected χ² | Moderate (N > 20, E ≈ 5) | Independent groups | Reduces chi-square over-optimism by subtracting 0.5 from |O - E|. |
| McNemar's Test | Any sample size | Paired / Repeated Measures | Matched case-control or pre-post binary tests on the exact same subjects. |
| Barnard's Exact Test | Small samples | Independent groups (unconditional) | Unconditional test that does not fix both margins; slightly higher statistical power. |
Historical Origin: The “Lady Tasting Tea” Experiment
At Rothamsted Experimental Station in the late 1920s, Dr. Muriel Bristol asserted that she could taste whether milk or tea had been poured into a cup first. Her colleague, the statistician Ronald A. Fisher, designed a rigorous blinded randomized trial with 8 cups of tea: 4 with milk poured first, and 4 with tea poured first.
Dr. Bristol successfully identified 3 of the 4 milk-first cups (cell a = 3). Under Fisher's exact hypergeometric calculation, the probability of correctly identifying all 4 cups by pure luck is &binom;(4,4)×&binom;(4,0)/70 = 1/70 ≈ 0.0143. The probability of identifying at least 3 cups is (1 + 16)/70 = 17/70 ≈ 0.2429. This famous milestone laid the foundation for modern randomized experimental design and exact hypothesis testing!
Verifying Results in R, Python, and SPSS
Our calculator produces outputs that match the scientific computing industry standards:
# 2x2 matrix: matrix(c(a, c, b, d), nrow=2)
# R fills columns first!
mat <- matrix(c(3, 1, 1, 3), nrow = 2,
dimnames = list("Treatment" = c("Yes", "No"),
"Outcome" = c("Success", "Fail")))
# Two-sided Fisher's Exact Test:
fisher.test(mat, alternative = "two.sided")
# One-sided Right:
# fisher.test(mat, alternative = "greater")from scipy.stats import fisher_exact
# Table format: [[a, b], [c, d]]
table = [[3, 1],
[1, 3]]
# Two-sided test:
odds_ratio, p_value = fisher_exact(table, alternative='two-sided')
print("Odds Ratio:", odds_ratio)
print("Two-sided p-value:", p_value)
# One-sided right test:
# res = fisher_exact(table, alternative='greater')Frequently Asked Questions
Related Calculators
Created by William Davis
Last updated: October 14, 2026