Fisher's Exact Test Calculator

Perform Fisher's exact test on 2×2 contingency tables. Calculate exact p-value, odds ratio, relative risk, and view every possible table in the hypergeometric distribution.

Fisher\'s Exact Test Calculator

2×2 Contingency Table

Outcome +Outcome −
Group 1
Group 2
p-Value (Fisher\'s Exact)
0.0414
Significant at α = 0.05
Decision
Reject H₀
Significant association between variables
Odds Ratio
8.0000
Group 1 has higher odds of Outcome +
Relative Risk
2.1667
Ratio of outcome probability: Group 1 / Group 2
Total Sample Size
25
Row totals: 12, 13 | Column totals: 15, 10
Observed Table Probability
0.025986
Hypergeometric probability of the exact observed table

Expected vs Observed

Outcome +Outcome −Total
Group 1 (Obs)10212
Group 1 (Exp)7.204.8012
Group 2 (Obs)5813
Group 2 (Exp)7.805.2013

Probability Distribution (All Possible Tables)

abcdProbability
2101302.019e-5
391210.0009
481120.0118
571030.0693
66940.2021
75850.3118
84760.2599
93670.1155
102580.0260← observed
111490.0026
1203108.749e-5

Visual: Probability Distribution

a=2
0.0000
a=3
0.0009
a=4
0.0118
a=5
0.0693
a=6
0.2021
a=7
0.3118
a=8
0.2599
a=9
0.1155
a=10
0.0260
a=11
0.0026
a=12
0.0001
Planning notes, formulas, and examples

About the Fisher's Exact Test Calculator

Fisher's exact test is the gold standard for testing association in 2×2 contingency tables, especially when sample sizes are small. Unlike the chi-square test, which relies on a large-sample approximation, Fisher's test computes the exact probability of observing the data (or more extreme data) under the null hypothesis of no association.

This calculator lets you enter a 2×2 table directly or choose from preset examples. It computes the exact two-sided, left-tail, and right-tail p-values using the hypergeometric distribution, along with the odds ratio, relative risk, expected frequencies, and a complete enumeration of all possible tables with the same marginal totals.

Fisher's exact test is widely used in biomedical research (clinical trials with small samples), genetics (rare allele associations), ecology (species distribution), quality control (defect counts), and any field where categorical data is analyzed with limited observations. Use the example to see how the exact p-value comes from enumerating all 2×2 tables with the same margins, especially when expected counts are small.

When This Page Helps

The chi-square test can give misleading p-values when expected cell counts fall below 5. Fisher's exact test avoids this problem entirely by computing exact probabilities from the hypergeometric distribution. This calculator handles all the combinatorial math for you and displays every possible table configuration, letting you see exactly how the p-value is constructed.

How to Use the Inputs

  1. Enter the four cell counts of your 2×2 contingency table (a, b, c, d).
  2. Or click a preset example to load common scenarios.
  3. Choose your alternative hypothesis: two-sided, less, or greater.
  4. Set your significance level alpha (default 0.05).
  5. Review the exact p-value and reject/fail-to-reject decision.
  6. Check the odds ratio and relative risk for effect size.
  7. Examine the probability distribution table to see all possible tables and their probabilities.
Formula used
Fisher's Exact Test (Hypergeometric distribution): P(a) = C(a+b, a) × C(c+d, c) / C(n, a+c) = (a+b)! × (c+d)! × (a+c)! × (b+d)! / (n! × a! × b! × c! × d!) Two-sided p-value: Sum of P(table) for all tables as extreme or more extreme than observed Odds Ratio: OR = (a × d) / (b × c) Relative Risk: RR = (a/(a+b)) / (c/(c+d))

Example Calculation

Result: p = 0.0432, OR = 8.0

With a = 10, b = 2, c = 5, d = 8 (n = 25), the two-sided Fisher's exact p-value is 0.0432. The odds ratio of 8.0 indicates that Group 1 has 8 times the odds of a positive outcome compared to Group 2. At α = 0.05, we reject the null hypothesis of no association.

Tips & Best Practices

  • Fisher's exact test is always valid regardless of sample size — use it whenever you have a 2×2 table, especially with small samples.
  • For large samples, Fisher's exact test and the chi-square test give nearly identical results, but Fisher's is computationally slower.
  • The odds ratio is the primary effect size. An OR of 1 means no association; OR > 1 or < 1 indicates direction.
  • Two-sided p-values sum probabilities of all tables as extreme or more extreme in both directions.
  • Fisher's test assumes fixed margins (both row and column totals are fixed). In practice, this assumption is often approximately met.
  • For tables larger than 2×2, Fisher's exact test becomes computationally expensive — chi-square is typically preferred.

The Hypergeometric Framework

Fisher's exact test is based on the hypergeometric distribution. Given fixed row and column totals, only one cell value (conventionally a) is free to vary. The test enumerates every possible value of a and its probability, then sums probabilities for tables as extreme or more extreme than observed. This exactness is the test's greatest strength.

Odds Ratio and Relative Risk

While both measure association, they differ in interpretation. The odds ratio (OR = ad/bc) compares odds, while relative risk (RR) compares probabilities. OR is always valid for case-control studies, while RR is appropriate for cohort studies and clinical trials. When the outcome is rare, OR approximates RR — this is the rare disease assumption.

Historical Context and Modern Usage

R. A. Fisher developed this test in the 1920s, famously applied to the "lady tasting tea" experiment. Today it's a standard tool in clinical trials, genetic association studies, and any small-sample categorical analysis. Most statistical software and online tools provide Fisher's exact test alongside chi-square for contingency tables.

Sources & Methodology

Last updated:

Frequently Asked Questions

  • Use Fisher's exact test when any expected cell frequency is below 5, when the total sample size is small (under 20-30), or when you want exact rather than approximate p-values. For large samples, both tests give similar results.