Fisher's Exact Test Calculator

Enter the four counts of a 2×2 contingency table to get the exact one-tailed and two-tailed p-values and the odds ratio, computed directly from the hypergeometric distribution.

Quick Facts

Method
Exact hypergeometric probability over all tables with the same margins
Valid for any sample size, unlike the chi-square approximation.

Your Results

Calculated
Two-tailed p-value
-
Test of association (both directions)
One-tailed p-value
-
Smaller of the two one-sided tails
Odds ratio
-
(a×d) / (b×c)
Probability of this table
-
Hypergeometric point probability

Ready

Enter the four cell counts and run the test.

What Fisher's exact test does

Fisher's exact test measures whether two categorical variables in a 2×2 contingency table are associated. You arrange your data as four counts — cells a, b, c and d — and the test returns the exact probability of seeing a table at least as extreme as yours if the two variables were in fact independent. Unlike the chi-square test, it makes no large-sample approximation, so it is valid even when the counts are tiny.

The classic illustration is R. A. Fisher's "lady tasting tea." A woman claimed she could tell whether milk or tea was poured into the cup first. Given 8 cups — 4 milk-first and 4 tea-first — she correctly identified 3 of the 4 milk-first cups, giving the table below. Fisher's test asks: how likely is that hit rate by pure guessing?

The 2×2 table and the formula

Label the table so that a and b are the top row, c and d the bottom row:

Column 1Column 2Row total
Row 1aba+b
Row 2cdc+d
Col totala+cb+dn

With all four margins (row totals and column totals) held fixed, the probability of any particular table follows the hypergeometric distribution:

P = [ (a+b)! × (c+d)! × (a+c)! × (b+d)! ] / [ a! × b! × c! × d! × n! ]

To get the two-tailed p-value, the calculator enumerates every possible table that keeps the same margins, computes each table's probability, and adds up the probabilities of all tables that are as likely or less likely than your observed table. The one-tailed p-value sums the probabilities in a single direction (the tail your table falls in) and is always the smaller of the two one-sided sums reported here.

A worked example: the lady tasting tea

Her result is a = 3, b = 1, c = 1, d = 3 (3 milk-first cups called correctly, 1 missed; 1 tea-first cup wrongly called milk-first, 3 correct). The probability of exactly this table is 0.2286. Summing the equally-or-less-likely tables gives a two-tailed p-value of 0.4857 and a one-tailed p-value of 0.2429. Because 0.4857 is far above 0.05, guessing 3 of 4 is not strong enough evidence of real ability. The sample odds ratio here is (3×3)/(1×1) = 9.

The odds ratio

Alongside the p-value the calculator reports the sample odds ratio, (a×d)/(b×c). It summarizes the direction and strength of the association: 1 means no association, values above 1 a positive association, and values below 1 a negative one. Note this is the simple cross-product odds ratio; statistical software such as R reports a conditional maximum-likelihood estimate instead, which can differ slightly. If b or c is zero the odds ratio is infinite, and if a or d is zero it is zero, so it is shown as undefined in those cases.

When to use it

  • Any expected cell count is small — the usual trigger is an expected count below 5, where the chi-square approximation is unreliable.
  • Total sample size is small (often under about 20–40), a common situation in early-stage clinical, laboratory, or A/B pilot data.
  • You have exactly two rows and two columns of counts. For larger tables use the Freeman-Halton extension of Fisher's test instead.

Frequently Asked Questions

When should I use Fisher's exact test instead of a chi-square test?
Use Fisher's exact test for a 2×2 table when any expected cell count is small — the common rule of thumb is when any expected count is below 5. The chi-square test relies on a large-sample approximation that becomes inaccurate with small counts, whereas Fisher's exact test computes the exact probability from the hypergeometric distribution, so it is valid for any sample size.
What does the p-value mean here?
Holding all four row and column totals fixed, the test computes the hypergeometric probability of every possible table. The two-tailed p-value is the sum of the probabilities of all tables whose probability is less than or equal to that of your observed table. A small p-value means your table is an unlikely arrangement under the null hypothesis of no association between the two variables.
Should I report the one-tailed or two-tailed p-value?
Use the two-tailed p-value unless you had a specific directional hypothesis stated before collecting data. The two-tailed value tests for any association; the one-tailed value only tests for an association in one predicted direction and is roughly half as large, so reporting it after seeing the data inflates the apparent significance.
Why does my odds ratio differ from the one in R or SPSS?
This calculator reports the sample (cross-product) odds ratio, (a×d)/(b×c). R's fisher.test reports a conditional maximum-likelihood estimate based on the noncentral hypergeometric distribution, which is a different estimator and usually a bit closer to 1. Both describe the same association; they just estimate it differently.