Fisher's Exact Test Calculator
Enter the four cells of your 2x2 contingency table and choose one-tailed or two-tailed. The calculator returns the exact p-value, odds ratio with 95% confidence interval, relative risk, and a plain-English interpretation of the result. No approximations, no chi-square assumptions. Works for any sample size, including very small ones.
Formula
Worked example
Suppose 10 patients receive a treatment and 10 receive a placebo. 8 treated patients improve (a=8, b=2) vs 1 placebo patient (c=1, d=9). The two-tailed p-value from exact enumeration is 0.0130, well below 0.05. OR = (8*9)/(2*1) = 36, meaning treated patients have 36x higher odds of improving. RR = (8/10)/(1/10) = 8: the treated group improves 8 times as often.
What is Fisher's exact test?
Fisher's exact test is a statistical test of independence for data arranged in a 2x2 contingency table. Unlike the chi-square test, which uses an approximation, Fisher's test computes the exact probability of observing a table at least as extreme as the one you collected, given fixed marginal totals. It was derived by Ronald A. Fisher in 1922 and is especially valuable when sample sizes are small or when expected cell counts fall below 5, the threshold below which chi-square approximations become unreliable. The test works by enumerating all possible 2x2 tables with the same row and column totals and summing the hypergeometric probabilities of those that are at least as extreme as the observed table.
Setting up the 2x2 table
Your four cells correspond to cross-tabulating two binary variables: the rows label one variable (e.g. exposed vs unexposed, treatment vs control) and the columns label the other (e.g. event vs no event, case vs control). Cell a is the count of row-1 observations in column 1, b is row 1/column 2, c is row 2/column 1, and d is row 2/column 2. The four marginal totals (row sums and column sums) are treated as fixed by the test, which is one reason it produces exact rather than approximate p-values. If your table has more than two rows or two columns, use a chi-square test instead.
Odds ratio, relative risk, and confidence interval
The odds ratio (OR) is (a*d)/(b*c). An OR of 1 means equal odds; OR > 1 means the event is more likely in row 1; OR < 1 means it is less likely. The relative risk (RR) is the risk in row 1 divided by the risk in row 2, where risk = events/total in that row. RR is more intuitive than OR when absolute risks are far from 0 or 1. The 95% confidence interval for the OR is computed using the Woolf log-OR method: exp(ln(OR) +/- 1.96 * sqrt(1/a + 1/b + 1/c + 1/d)). When any cell is zero, the calculator applies the Haldane-Anscombe correction (adding 0.5 to each cell) before computing the CI.
One-tailed vs two-tailed
Choose two-tailed unless you stated a directional hypothesis before collecting data. A two-tailed test asks: 'Is there any association?' and sums probabilities on both sides of the distribution. A one-tailed test asks a directional question such as 'Is the event more common in row 1?' and sums probabilities only in one tail. Using one-tailed when you did not pre-specify the direction inflates type I error. If you are unsure, two-tailed is the safe default and is what most journals expect.
Common significance thresholds for the p-value
| p-value range | Interpretation | Significance level |
|---|---|---|
| < 0.001 | Highly significant | p < 0.001 |
| 0.001 to 0.01 | Very significant | p < 0.01 |
| 0.01 to 0.05 | Significant | p < 0.05 |
| 0.05 to 0.10 | Marginal (trend) | p < 0.10 |
| > 0.10 | Not significant | p >= 0.10 |
Fisher's exact test returns an exact p-value. Compare it against whichever alpha level was pre-specified.
Frequently asked questions
When should I use Fisher's exact test instead of chi-square?
Use Fisher's exact test when any expected cell count is below 5 or when your total sample size is below about 20. Expected cell count = (row total * column total) / N. For larger samples with expected counts >= 5 in all cells, the chi-square approximation is acceptable, but Fisher's test still gives the exact answer. Many statisticians use Fisher's by default for all 2x2 tables, since it is always valid and software can compute it quickly.
What does 'exact' mean in Fisher's exact test?
The word 'exact' means the p-value is computed from the exact hypergeometric probability distribution rather than an approximation such as the chi-square distribution. The test enumerates every possible 2x2 table that has the same marginal totals as the observed table, computes each table's probability, and sums those that are at least as extreme as the observed one. The result is mathematically exact under the assumption of fixed marginals.
What is the null hypothesis of this test?
The null hypothesis is that the two categorical variables are independent, meaning the row assignment (e.g. exposed vs unexposed) has no effect on the probability of the column outcome (e.g. event vs no event). Equivalently, the null hypothesis states that the odds ratio equals 1 in the population. A small p-value is evidence against this independence assumption.
Why does the calculator cap the table size at N = 300?
Exact enumeration requires iterating over all possible 2x2 tables with the same marginal totals. For very large N (say N = 1000 with col1 = 500), there are hundreds of possible tables and the log-factorial computation becomes slow in a browser. At N > 300 the chi-square test or a normal approximation is highly accurate (expected cell counts are almost certainly >= 5), so the approximation introduces negligible error. Use statistical software for very large tables.
What does an odds ratio greater than 1 mean?
An odds ratio (OR) > 1 means the event is more likely (higher odds) in row 1 than in row 2. For example, OR = 3 means the odds of the event are 3 times higher in row 1. OR = 1 means no difference. OR < 1 means the event is less likely in row 1. Always report the 95% confidence interval alongside the OR: if the interval contains 1, the association is not statistically significant at the 5% level.