Fisher’s Exact Test Calculator

Quick answer

The Fisher's exact test calculator finds the exact one- and two-tailed p-values for a 2×2 contingency table from the hypergeometric distribution. It also reports the odds ratio with an approximate confidence interval and charts the probability of every table with the same margins.

p-value for the chosen alternative
2.76e-3
Decision
Reject H₀ (independence) at α = 0.05 – p = 0.0028 ≤ 0.05.
Two-tailed p-value
2.76e-3
Left-tailed p-value P(X ≤ a)
1.38e-3
Right-tailed p-value P(X ≥ a)
1
Odds ratio (ad ÷ bc)
0.0303
95% confidence interval for the odds ratio
95% CI: 0.0027 to 0.3437 (Woolf, approximate)
Probability of the observed table
1.35e-3
Total count
24
Table with totals
Column 1 Column 2 Total ─────────────────────────────────── Row 1 1 9 10 Row 2 11 3 14 Total 12 12 24
Probability of each table with the same margins

Fisher’s exact test checks whether two yes/no variables are associated (for example, whether a treatment changes the chance of recovery) using a 2×2 table of counts. Unlike the chi-square test it does not rely on a large-sample approximation. Instead it fixes the row and column totals and asks how likely each possible arrangement of the four cells would be if there were no association.

With the margins fixed, the count in the top-left cell follows a hypergeometric distribution, so the probability of every possible table can be computed exactly. The one-tailed p-value adds up the tables at least as extreme as yours in one direction. The two-tailed p-value adds up all tables that are no more probable than the one you observed, which is the method used by R and most statistics packages.

The test was devised by Ronald Fisher for the famous “lady tasting tea” experiment. It is the method of choice when samples are small or when any expected count is below 5, and it remains valid for large samples, although it becomes slow to compute by hand.

How to use the Fisher’s Exact Test Calculator

  1. Row 1, column 1 (a)
  2. Row 1, column 2 (b)
  3. Row 2, column 1 (c)
  4. Row 2, column 2 (d)
  5. Alternative hypothesis
  6. Significance level (α)

Everything is calculated in your browser, so results appear instantly and nothing you type is sent to a server.

How it works

Enter the four cell counts. The calculator computes the hypergeometric probability of every table that shares your row and column totals, then adds the probabilities of the tables that are as extreme as or more extreme than yours for the chosen alternative.

Worked example

In a small study, 1 of 10 men and 11 of 14 women are dieting (table 1, 9 / 11, 3). With the margins fixed (12 dieters, 10 men, 24 people) the probability of exactly this table is C(10, 1) × C(14, 11) ÷ C(24, 12) = 0.00135.

Adding the probabilities of all tables that are no more likely gives the two-tailed p = 0.0028, so dieting is associated with sex at α = 0.05. The left-tailed p-value P(X ≤ 1) = 0.0014. The sample odds ratio is (1 × 3) ÷ (9 × 11) = 0.030.

For the classic tea-tasting table (3, 1 / 1, 3) the right-tailed p-value is 16/70 + 1/70 = 0.243 and the two-tailed p-value 0.486.

How to read the result

A small p-value means a split as uneven as yours would rarely happen by chance if the two variables were unrelated. The odds ratio shows the direction and size: below 1, the outcome in column 1 is less likely in row 1; above 1, more likely. Because the confidence interval for the odds ratio here uses Woolf’s approximation, it can disagree slightly with the exact p-value in very small tables.

Formula

P(table) = C(a + b, a) × C(c + d, c) ÷ C(n, a + c) = (a + b)! (c + d)! (a + c)! (b + d)! ÷ (n! a! b! c! d!) · two-tailed p = Σ P(tables with P ≤ P(observed)) · odds ratio = ad ÷ bc

Worked example

Inputs: Row 1, column 1 (a): 1; Row 1, column 2 (b): 9; Row 2, column 1 (c): 11; Row 2, column 2 (d): 3; Alternative hypothesis: Two-tailed – any association; Significance level (α): 0.05.
Results: p-value for the chosen alternative = 2.76e-3; Decision = Reject H₀ (independence) at α = 0.05 – p = 0.0028 ≤ 0.05.; Two-tailed p-value = 2.76e-3; Left-tailed p-value P(X ≤ a) = 1.38e-3; Right-tailed p-value P(X ≥ a) = 1; Odds ratio (ad ÷ bc) = 0.0303.

Key terms

Contingency table
A table of counts classified by two categorical variables.
Hypergeometric distribution
The distribution of the number of successes when drawing without replacement, here the count in cell a given the margins.
Marginal totals
The row and column sums, held fixed by Fisher's test.
Odds ratio
(a ÷ b) ÷ (c ÷ d); 1 means no association.

Frequently asked questions

When should I use Fisher's exact test instead of chi-square?

When the sample is small or any expected cell count is below 5. Fisher's test is exact for any sample size, while chi-square is an approximation.

What did the lady tasting tea experiment show?

A lady identified the order (milk or tea first) of 8 cups, 4 of each. Getting 3 of 4 right gives a one-tailed p of 0.243, and all 4 right gives p = 1/70 = 0.014.

How is the two-tailed p-value calculated?

By adding the probabilities of all tables with the same margins whose probability is no larger than that of the observed table. This is what R's fisher.test does.

Can Fisher's test handle tables larger than 2×2?

The idea extends to r × c tables (the Freeman–Halton test), but this calculator covers the common 2×2 case. For larger tables with big counts use the chi-square test.

Why is my odds ratio infinite?

Because b or c is zero, so ad ÷ bc divides by zero. The p-value is still valid; report the odds ratio as "not estimable" or use a corrected estimate.

Is Fisher's test too conservative?

Because the data are discrete, the actual false-positive rate is often below α. A mid-p-value (subtracting half the observed table's probability) is a common, less conservative alternative.

Does this odds ratio match R's output?

R reports a conditional maximum-likelihood estimate, which differs slightly from the simple sample odds ratio ad ÷ bc shown here. The p-values are identical.

Sources

  1. Wikipedia: Fisher's exact test
  2. NIST/SEMATECH e-Handbook of Statistical Methods
  3. Penn State STAT 500: Applied Statistics

Cite this calculator

Speedy Calculator. (2026). Fisher’s Exact Test Calculator. Speedy Calculator. https://speedycalculator.com/calculators/statistics/fishers-exact-test/