Fisher's Exact Test Calculator

Enter the observed counts for your 2×2 contingency table. Fisher's Exact Test computes the exact p-value for testing whether two categorical variables are independent — especially suitable for small sample sizes where the chi-square approximation may not be valid.

Customize variable and category names (optional):
Success Failure Row Total
Exposed 17
Unexposed 13
Column Total 15 15 30
Fisher's Exact Test Online Calculator

How to Use This Calculator

Follow these steps to perform Fisher's Exact Test on your 2×2 contingency table:

1Set Up Your Table

Enter the observed counts into the four cells of the 2×2 table (a, b, c, d). Each cell must be a non-negative integer. Optionally, customize the row and column labels to match your study's variables (e.g., "Drug A / Placebo" and "Recovered / Not Recovered").

2Check Expected Counts

The calculator will automatically show whether any expected cell count is below 5. If so, Fisher's Exact Test is the appropriate choice over the chi-square test.

3Click Calculate

Click the Calculate button to get:

4Interpret Your Results

💡 Tip: Fisher's Exact Test is always valid, but is especially recommended when any expected cell frequency is less than 5 or the total sample size is less than 20. For larger samples, the chi-square test gives very similar results.
⚠️ Note: Fisher's Exact Test is designed for independent observations. If your data involves matched pairs (e.g., before/after measurements on the same subject), use McNemar's test instead.

Understanding Fisher's Exact Test

Fisher's Exact Test is a statistical significance test used to analyze 2×2 contingency tables. It determines whether there is a nonrandom association between two binary categorical variables. Unlike the chi-square test, which uses an approximation, Fisher's test calculates the exact probability of observing the data given the null hypothesis of independence.

The test was developed by Ronald Fisher in 1922. The name "exact" refers to the fact that no approximation is needed — it computes the exact hypergeometric probability of the observed and more extreme tables.

When to Use Fisher's Exact Test

The 2×2 Contingency Table

Data for Fisher's test is arranged in a 2×2 table with four cells:

Outcome: YesOutcome: NoRow Total
Group 1 (Exposed)aba + b
Group 2 (Unexposed)cdc + d
Column Totala + cb + dN = a+b+c+d

The Formula

The exact p-value is calculated by summing the hypergeometric probabilities of all tables as extreme or more extreme than the observed one. The probability of any single table with fixed marginals is:

$$ P = \frac{\binom{a+b}{a}\binom{c+d}{c}}{\binom{N}{a+c}} = \frac{(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.

Odds Ratio

The odds ratio (OR) measures the strength of association:

$$ OR = \frac{a \times d}{b \times c} $$

The 95% confidence interval for the odds ratio uses the Woolf (log) method:

$$ \ln(OR) \pm 1.96 \times \sqrt{\frac{1}{a} + \frac{1}{b} + \frac{1}{c} + \frac{1}{d}} $$

Relative Risk (Risk Ratio)

The relative risk (RR) compares the probability of the outcome in each group:

$$ RR = \frac{a/(a+b)}{c/(c+d)} $$

Examples with Step-by-Step Solutions

Example 1: Drug Treatment Study

A researcher tests a new drug on 20 patients: 10 receive the drug, 10 receive a placebo. Results after treatment:

RecoveredNot RecoveredTotal
Drug8210
Placebo4610
Total12820

Step 1: State the Hypotheses

H₀: There is no association between treatment and recovery (drug and recovery are independent).

H₁: There is an association between treatment and recovery.

Step 2: Check Expected Counts

Expected count for cell (Drug, Recovered) = (10 × 12) / 20 = 6. Since all expected counts ≥ 5, either test could be used, but Fisher's is still valid.

Step 3: Calculate the Probability of the Observed Table

$$ P_{observed} = \frac{10!\,10!\,12!\,8!}{20!\,8!\,2!\,4!\,6!} \approx 0.1032 $$

Step 4: Sum Probabilities of All Tables as Extreme or More Extreme

For a two-tailed test, we sum all table probabilities ≤ P(observed). In this case, the two-tailed p-value ≈ 0.1698.

Step 5: Conclude

Since p ≈ 0.17 ≥ 0.05, we fail to reject the null hypothesis. There is insufficient evidence to conclude the drug significantly affects recovery at the α = 0.05 level.

Odds Ratio = (8 × 6) / (2 × 4) = 6.0, suggesting a 6-fold higher odds of recovery with the drug, though not statistically significant given the small sample.


Example 2: Epidemiological Study (Small Sample)

An epidemiologist studies whether exposure to a chemical is associated with disease in a small population of 15 subjects:

DiseaseNo DiseaseTotal
Exposed516
Unexposed279
Total7815

Why Fisher's Exact Test?

Expected count for "Exposed, No Disease" = (6 × 8) / 15 = 3.2 < 5. The chi-square approximation is invalid here — Fisher's Exact Test is required.

Result

Two-tailed p-value ≈ 0.0559. Odds Ratio = (5 × 7) / (1 × 2) = 17.5, indicating a strong association. Though p is just above 0.05, the large OR and small sample size suggest the study may be underpowered.


Frequently Asked Questions (FAQ)

Q1: Is Fisher's Exact Test always better than the chi-square test?

Not necessarily. Fisher's test is always valid, but for large samples both tests give virtually identical results. Chi-square is computationally simpler for large samples. Fisher's test is specifically recommended when expected cell counts are < 5 or sample sizes are small.

Q2: What is the difference between one-tailed and two-tailed p-values?

A two-tailed test (default) tests whether the association goes in either direction — whether group 1 has higher or lower odds. A one-tailed test tests a specific direction (e.g., group 1 has strictly higher odds). Use a one-tailed test only if you had a directional hypothesis before collecting data. The two-tailed p-value is always ≥ the one-tailed p-value.

Q3: Can Fisher's Exact Test be used for tables larger than 2×2?

Yes — extensions exist for r×c tables (called the Fisher-Freeman-Halton test), but the computation becomes very intensive. This calculator focuses on the standard 2×2 case.

Q4: What does a confidence interval for the odds ratio mean?

A 95% CI for the OR that does not include 1.0 corresponds to a statistically significant result at α = 0.05. For example, OR = 4.5 (95% CI: 1.2–17.0) means the true OR is likely between 1.2 and 17.0, and since 1.0 is excluded, the result is significant.

Q5: How is Fisher's test different from McNemar's test?

Fisher's Exact Test requires independent groups (e.g., two different groups of patients). McNemar's test is used for paired/matched data (e.g., the same patients measured before and after treatment).

Related Statistical Calculators