Chi-Square CalculatorChi-Square Calculator
Exact tests

Fisher's Exact Test Calculator

Enter a 2x2 table. Fisher's exact test gives a p-value without the large-sample approximation behind chi-square, so it works even when counts are tiny.

Guessed milkGuessed tea
Milk first (truth)
Tea first (truth)
p-value, greater0.2429
Sample odds ratio (ad/bc)9.0000
Conditional MLE odds ratio (R)6.4083
95% CI (conditional)0.3136 to infinity
Alternativep-value
Two-sided0.4857
Less0.9857
Greater0.2429

The two-sided p adds the probabilities of every table, with the same row and column totals, that is no more likely than yours. R and SciPy both use this definition; some textbooks double the one-sided p instead, which can give a different answer.

p is not below 0.05: no evidence of an association at the 5% level.

Probability of this exact table: 0.228571. N = 8.

Reproduce this result in R or Python

R

tab <- matrix(c(3, 1, 1, 3), nrow = 2, byrow = TRUE)
fisher.test(tab, alternative = "greater", conf.level = 0.95)

Python (SciPy)

from scipy.stats import fisher_exact, contingency
tab = [[3,1],[1,3]]
print(fisher_exact(tab, alternative="greater"))   # sample odds ratio ad/bc and p
res = contingency.odds_ratio(tab)   # conditional MLE, as R
print(res.statistic, res.confidence_interval(confidence_level=0.95, alternative="greater"))

Checked on November 21, 2026. Results computed by our statistics engine, version 1.0.0.

On this page

How the exact test works

Fix the row and column totals of your table. Every table with those totals has a probability given by the hypergeometric distribution if rows and columns are unrelated. The one-sided p-value adds the probabilities of your table and every table more extreme in one direction. The two-sided p-value, as R and SciPy compute it, adds the probabilities of every table no more likely than yours (SciPy fisher_exact).

Because nothing is approximated, the test is valid however small the counts. The price is that it is conservative when the totals were not fixed by the design: its true error rate is usually below the nominal 5%.

Worked example: Fisher's tea-tasting lady

In The Design of Experiments (1935) Fisher described a lady who claimed she could tell whether milk or tea was poured first. She was given 8 cups, half of each kind, and identified 3 of the 4 milk-first cups correctly. R uses this as its fisher.test example (R reference output), and it is pre-filled above.

Guessed milkGuessed tea
Milk first31
Tea first13

The question is one-sided: can she do better than guessing? The p-value for "greater" is 0.2429, so 3 out of 4 correct is not convincing; pure guessing does at least that well about one time in 4. The two-sided p is 0.4857.

The sample odds ratio is 9.0. R prints a different number, 6.4083, the conditional maximum likelihood estimate, with a one-sided 95% interval from 0.3136 to infinity. R finds these with a numerical root finder at a loose tolerance, so its printed values can differ from ours in the fourth or fifth significant figure; our values are solved to full precision.

A significant example: twins and convictions

R's second example is Fisher's 1962 data on convictions among the same-sex twins of convicted criminals: 2 of the 17 dizygotic twins were also convicted, against 10 of the 13 monozygotic twins. The first row of the table holds the convicted twins and the second row the others. The two-sided p is 5.367 × 10−4 and the conditional odds ratio is 0.0469, with a 95% confidence interval from 0.0033 to 0.3632. Strong evidence of an association.

SciPy's documentation uses a third table, 8 and 2 over 1 and 5, with sample odds ratio 20.0 and two-sided p = 0.0350. Enter it above to compare.

Which odds ratio to report

  • Sample odds ratio, ad / bc: what SciPy's fisher_exact returns and what most people compute by hand. Not defined when b or c is zero.
  • Conditional maximum likelihood estimate: what R's fisher.test prints, with an exact confidence interval that matches the test. It is pulled toward 1 compared with the sample odds ratio, most visibly in small tables.
  • Label which one you report. Both appear in the result above.

Fisher or chi-square?

For a 2x2 table with an expected count below 1, use Fisher's test. With expected counts of at least 1 but some below 5, Campbell (2007) recommends the N−1 chi-square instead, because Fisher's test is conservative. The 2x2 calculator shows every option and the expected counts guide explains the rules. Tables larger than 2x2 need the Freeman-Halton extension, which this page does not compute; the test of independence calculator flags small expected counts in larger tables.

Common questions

Is Fisher's test only for small samples?

No. It is valid for any size, but chi-square gives almost the same answer once expected counts are large, and is faster to compute by hand.

Why does doubling the one-sided p not give your two-sided p?

Some textbooks define the two-sided p that way. R and SciPy add the probabilities of all tables no more likely than the observed one, which differs when the margins are uneven. We follow R and SciPy.

Why does R show a different odds ratio?

R reports the conditional maximum likelihood estimate; ad/bc is the sample odds ratio. Both are shown above.

Sources