Fisher's Exact Test Calculator

Exact p-values for 2×2 contingency tables via the hypergeometric distribution. Larger r×c tables use the chi-square test of independence instead.

Paste a 2×2 table of counts, one row per line, the counts separated by tabs, commas or spaces:

When to use Fisher instead of chi-square

Fisher's exact test conditions on fixed margins and sums exact hypergeometric probabilities. Use it for 2×2 tables with small expected counts; for larger tables see chi-square independence.

Lady tasting tea (Load example)

Table [[1, 9], [11, 3]]: two-sided p ≈ 0.00276, sample OR ≈ 0.0303. The exact test rejects no association at α = 0.01. See also hypergeometric distribution.

P(table) = (n₁ choose a)(n₂ choose c) / (N choose n₁)

Related guides and calculators

For larger counts the chi-square test of independence gives a similar answer, and for paired yes/no data use the McNemar test. The strength of the association is the odds ratio or the relative risk; a test that classifies patients is summarized by sensitivity and specificity. See relative risk vs odds ratio and sensitivity, specificity, PPV and NPV explained.

Frequently Asked Questions

Does this work for 3×3 tables?

No. Exact tests for general r×c tables are not offered here; use the chi-square test of independence with caution or specialized software.

How is the two-sided p-value defined?

It is the sum of probabilities of all tables with probability less than or equal to the observed table, matching R fisher.test (relative tolerance 1e-7).

What is the sample odds ratio?

For cells a, b, c, d in row-major order, OR = (a×d)/(b×c). Zero in b or c makes the ratio undefined.

What is the conditional MLE odds ratio?

It is the noncentrality parameter of Fisher's noncentral hypergeometric distribution whose mean equals the observed top-left count; scipy reports it as odds_ratio(kind='conditional'). It is computed here only when N ≤ 120.

Is there a table size limit?

Exact p-values use log-space hypergeometric sums for any non-negative counts. Conditional OR and its exact CI are offered when the table total N ≤ 120 so results stay fast on the main thread.

What is the mid-p value?

Lancaster mid-p counts only half the probability mass of tables tied at the observed likelihood, often less conservative than the conventional two-sided exact p-value.

Python equivalent?

scipy.stats.fisher_exact(table, alternative='two-sided'|'less'|'greater').

Why condition on margins?

Under independence with fixed row and column totals, the only randomness left is how counts fall into cells—hypergeometric.

What is the relative tolerance 1e-7?

Tables whose probability is within 0.00001% of the observed table probability are included in the two-sided sum, matching R fisher.test.

One-sided vs two-sided?

Less sums tables with a ≤ a_observed; greater uses a ≥ a_observed; two-sided adds all tables at least as unlikely under the hypergeometric.

R equivalent?

fisher.test(matrix, alternative='two-sided') uses the same two-sided definition as this page and scipy.stats.fisher_exact.

Embed This Calculator

Add this free calculator to your course page or LMS.

Adjust the height value to fit your page.