Fisher's Exact Test Calculator
Fisher's exact test asks whether the two variables of a 2×2 contingency table are independent, without falling back on an approximate distribution: it works straight from probabilities. With the row and column totals held fixed, the hypergeometric probability of every table the data could have produced is computed one by one, and the probabilities of the tables at least as extreme as the observed one are added up.
The chi-square test is an APPROXIMATION based on the χ² distribution and it breaks down as expected frequencies get small; Fisher's test is valid at any sample size. Alongside the exact p-value, this calculator reports the probability of the observed table, the one-tailed p-values, the odds ratio with a confidence interval, and the chi-square results (Pearson and Yates) for the same table side by side, showing in numbers why a small sample calls for Fisher.
Fisher's Exact Test Formulas
Table: [a b; c d], N = a + b + c + d Hypergeometric: P(A = i) = C(a+b, i) · C(c+d, a+c−i) / C(N, a+c) Support: max(0, (a+c) − (c+d)) ≤ i ≤ min(a+b, a+c) Two-tailed: p = Σ P(A = i) over every i with P(A = i) ≤ P(observed) Left tail: p = P(A ≤ a) Right tail: p = P(A ≥ a) Odds ratio: OR = (a·d) / (b·c) SE(ln OR): √(1/a + 1/b + 1/c + 1/d) OR interval: exp(ln OR ± z · SE)
The two-tailed p is computed with the "every table no more likely than the observed one" rule (the minimum-likelihood / Irwin method), which matches R's fisher.test implementation. Doubling a one-tailed p gives a wrong answer whenever the table is not symmetric.
How to Calculate
- Enter the four cells of your 2×2 table: a and b are the outcome yes/no counts of the first group, c and d those of the second.
- Choose the confidence level for the odds ratio and the significance level for the decision.
- Read the two-tailed exact p-value; if your directional hypothesis was set in advance, use the matching one-tailed value.
- Look at the chi-square comparison rows: if the smallest expected frequency is below 5, the Pearson χ² p-value is unreliable and the exact p should be used instead.
- Report the odds ratio together with its confidence interval; if the interval contains 1, the effect is not statistically significant.
- In the hypergeometric chart, the highlighted bars are the tables that enter the two-tailed p, which shows visually how the p-value is built up.
Worked Examples
A clear difference in a small sample
Two groups of 10 subjects each; the outcome occurred in 1 subject in the first group and in 8 in the second. With a two-tailed exact p = 0.005 the difference is significant; the left-tail p is 0.003 and the probability of the observed table is 0.00268. The odds ratio is 0.028 (95% CI: 0.002 – 0.367). Because the smallest expected frequency is 4.50, the chi-square condition fails: on the same data Pearson χ² gives p = 0.002.
Exact p-value (two-tailed): p = 0.005 · Decision: Significant · Left-tail p — P(a ≤ observed): p = 0.003
In a large table, Fisher and chi-square agree
In a table of 100 people every expected frequency is 25.00. Fisher's exact p = 0.071, the Pearson χ² p = 0.046, and the Yates-corrected p = 0.072; since the expected frequency condition is met, all three methods stay close to one another. The odds ratio is 2.250 (95% CI: 1.011 – 5.008).
Exact p-value (two-tailed): p = 0.071 · Decision: Not significant · Left-tail p — P(a ≤ observed): p = 0.986
A table with a zero cell
No event was observed in the first group. The exact p = 0.014, so the difference is significant; a zero cell does not break the exact test. The odds ratio would be undefined, so with the Haldane-Anscombe correction it comes out as 0.040 (95% CI: 0.002 – 0.827).
Exact p-value (two-tailed): p = 0.014 · Decision: Significant · Left-tail p — P(a ≤ observed): p = 0.007