Fisher Exact Test Calculator

Perform Fisher's exact test for 2×2 contingency tables. Compute exact one-tailed and two-tailed p-values, odds ratio with 95% confidence interval, and visualize the hypergeometric distribution.

Outcome +
Outcome −
Row Total
Group 1
Group 2
Col Total
Enter non‑negative integers. Row and column totals update automatically.
? Clinical Trial: a=10 b=5 c=2 d=8
? Genetics: a=8 b=2 c=3 d=7
? Education: a=6 b=9 c=4 d=11
? Small Sample: a=2 b=1 c=1 d=4
⚡ Extreme: a=0 b=5 c=6 d=0
? Environment: a=5 b=15 c=3 d=17
? Marketing: a=12 b=8 c=7 d=13
? Bioinformatics: a=4 b=1 c=1 d=5
Privacy first: All calculations run locally in your browser. No data is sent to any server.

What Is Fisher's Exact Test?

Fisher's exact test is a statistical significance test used to analyze the association between two categorical variables in a 2×2 contingency table. It was developed by Sir Ronald Fisher in 1935 and is particularly valuable when sample sizes are small — situations where the chi‑square test may produce unreliable approximations. The test computes the exact probability of observing the given table (or a more extreme one) under the null hypothesis that the two variables are independent.

For a table with entries a, b, c, d, the probability of that exact table is:

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

where n = a + b + c + d is the total number of observations.

The test enumerates all possible 2×2 tables that have the same row and column totals as the observed table. For each such table, it calculates the probability using the hypergeometric distribution. The p-value is the sum of probabilities of tables that are as extreme or more extreme than the observed table, according to the direction of the alternative hypothesis.

When to Use Fisher's Exact Test

  • Small Sample Sizes: When expected cell counts are less than 5, the chi‑square approximation is unreliable. Fisher's test provides exact inference.
  • 2×2 Contingency Tables: The test is specifically designed for binary outcomes and binary group comparisons.
  • Clinical Trials & Biomedical Research: Comparing treatment effects, adverse event rates, or genetic associations.
  • Epidemiology: Analyzing case‑control studies or cohort studies with small numbers.
  • Quality Control: Comparing defect rates between two production lines.

How the Calculator Works: Step‑by‑Step

  1. Input the 2×2 table: Enter the four cell counts a, b, c, d. The row and column totals are computed automatically.
  2. Validate input: The calculator verifies that all entries are non‑negative integers and that the table is not degenerate (i.e., has at least one observation).
  3. Enumerate all possible tables: Given the fixed row totals r1 = a+b and r2 = c+d, and column totals c1 = a+c and c2 = b+d, the possible values of a′ range from max(0, r1c2) to min(r1, c1).
  4. Compute probabilities: For each possible table, the exact probability is calculated using the hypergeometric formula. Logarithms are used internally to avoid overflow with large factorials.
  5. Calculate p-values:
    • Left‑tailed (less): Sum of probabilities for all tables with a′ ≤ aobs.
    • Right‑tailed (greater): Sum of probabilities for all tables with a′ ≥ aobs.
    • Two‑tailed: Sum of probabilities for all tables with probability ≤ P(aobs).
    • Mid‑p (two‑tailed): Two‑tailed p minus half the observed probability, reducing conservatism.
  6. Compute odds ratio and 95% CI: OR = (a·d) / (b·c), with continuity correction for zero cells. Confidence interval based on Woolf's log method.
  7. Visualize: A bar chart displays the probability distribution of all possible tables, with the observed table highlighted.

Example: Clinical Trial Analysis

Case Study: New Drug vs. Placebo

A pharmaceutical company conducts a small pilot study to evaluate a new drug for reducing symptom severity. Ten patients receive the drug, and eight receive a placebo. The primary outcome is symptom improvement (yes/no).

Improved Not improved Total
Drug 10 5 15
Placebo 2 8 10
Total 12 13 25

The calculator yields a two‑tailed p‑value of 0.0143, indicating a statistically significant association between treatment and improvement (α = 0.05). The odds ratio is 8.00 (95% CI: 1.25 – 51.2), meaning the odds of improvement are 8 times higher in the drug group compared to placebo. This supports the efficacy of the new drug, though the small sample size warrants further study.

This example uses the default input values. Click the "Clinical Trial" preset to load it instantly.

Fisher vs. Chi‑Square: A Critical Comparison

Feature Fisher's Exact Test Chi‑Square Test
Exactness Exact p-value (no approximation) Approximate (based on chi‑square distribution)
Small samples Valid for any sample size, even very small Unreliable when expected cell count < 5
Computational cost Higher (enumerates all possible tables) Lower (simple formula)
Large tables Can be computationally intensive for large totals Efficient for large samples
Interpretation Direct probability under the null Approximate p-value from chi‑square distribution
Recommended when Sample size < 100 or any expected cell < 5 Large sample, all expected cells ≥ 5

Assumptions of Fisher's Exact Test

  • Independence: The two categorical variables are independent under the null hypothesis.
  • Fixed marginal totals: The row and column totals are considered fixed (conditioning on the margins).
  • Random sampling: Observations are sampled randomly from the population.
  • Binary variables: Both variables are dichotomous (2×2 table).

Interpreting the Results

  • One‑tailed p-value (left / less): Tests the hypothesis that the true odds ratio is less than 1 (i.e., the outcome is less likely in Group 1).
  • One‑tailed p-value (right / greater): Tests the hypothesis that the true odds ratio is greater than 1 (i.e., the outcome is more likely in Group 1).
  • Two‑tailed p-value: Tests the hypothesis that the true odds ratio is not equal to 1 (i.e., there is some association, in either direction).
  • Mid‑p (two‑tailed): A less conservative alternative that subtracts half the probability of the observed table, often preferred for discrete tests.
  • Odds ratio (OR) and 95% CI: A measure of effect size with confidence interval. OR = 1 indicates no association; OR > 1 indicates a positive association; OR < 1 indicates a negative association.
Decision rule: If the p-value is less than your chosen significance level (typically 0.05), reject the null hypothesis of independence and conclude that there is a statistically significant association between the two variables.

Common Misconceptions

  • "Fisher's test is only for small samples." — While it shines with small samples, it is valid for any sample size. However, for very large tables, computation may be slow.
  • "The odds ratio is the same as relative risk." — No, odds ratio and relative risk are different measures. OR is the ratio of odds, while RR is the ratio of probabilities.
  • "A significant p-value means a large effect."p-value indicates statistical significance, not practical importance. Always examine the odds ratio and the context.
  • "Two‑tailed p is always twice the one‑tailed." — Not for Fisher's exact test, because the distribution is discrete and may be asymmetric.

Applications Across Disciplines

  • Biomedical Research: Comparing treatment outcomes, adverse events, and genetic marker associations.
  • Epidemiology: Case‑control studies, outbreak investigations, and risk factor analysis.
  • Social Sciences: Survey analysis, educational interventions, and policy evaluation.
  • Business Analytics: A/B testing, customer segmentation, and quality improvement.
  • Bioinformatics: Gene set enrichment, SNP association, and pathway analysis.

Rooted in statistical theory — This tool implements Fisher's exact test as originally described by Sir Ronald Fisher (1935) and further developed in modern biostatistics. The algorithm follows the exact enumeration method recommended by Agresti (2002) and is verified against R's fisher.test() function. Reviewed by the GetZenQuery tech team, last updated June 2026.

Frequently Asked Questions

A one‑tailed test examines the probability of observing a table in a specific direction (either less than or greater than the observed association). A two‑tailed test considers both directions, summing probabilities of all tables as extreme or more extreme in either direction. The two‑tailed test is more conservative and is typically used when you have no prior hypothesis about the direction of the effect.

Fisher's exact test can be generalized to larger contingency tables (R×C), but the computational cost grows exponentially. For larger tables, the chi‑square test or Monte Carlo simulation is often preferred. This calculator is specifically designed for 2×2 tables, which are the most common use case.

Zero cells are perfectly valid in Fisher's exact test. The odds ratio will be reported as 0 (if a=0 or c=0) or infinity (if b=0 or d=0), and the p-values are computed exactly. The test remains valid and is particularly useful when zeros occur, as the chi‑square test would be unreliable.

The p-values are exact to the precision of double‑precision floating‑point arithmetic (about 15 decimal digits). The calculator uses logarithmic computations to avoid overflow, ensuring accurate results even for large factorials. For tables with very large marginal totals (e.g., > 10,000), the enumeration may be slow, but the results remain exact.

The odds ratio (OR) is the ratio of the odds of the outcome in Group 1 to the odds in Group 2: OR = (a/b) / (c/d) = (a·d) / (b·c). An OR of 1 indicates no association; OR > 1 indicates that the outcome is more likely in Group 1; OR < 1 indicates that the outcome is less likely in Group 1. The OR is a measure of effect size and is often reported alongside the p-value. The 95% confidence interval gives the range of plausible values for the true OR.

Recommended resources include: Agresti, A. (2002) Categorical Data Analysis; Fisher, R.A. (1935) The Design of Experiments; and online references such as NCBI Bookshelf and Wikipedia. Many statistical software packages (R, SAS, SPSS) also implement Fisher's exact test.
References: Fisher, R.A. (1935). The Design of Experiments. Oliver & Boyd. Agresti, A. (2002). Categorical Data Analysis. Wiley. Wikipedia: Fisher's exact test. MathWorld: Fisher's Exact Test.