Calculateus

Fisher's Exact Test Calculator

Calculate the exact p-value for a 2x2 contingency table, ideal for small sample sizes.

Result

Two-Tailed P-Value
0.06978

Fisher's Exact Test computes the exact probability of the observed table (and all tables at least as extreme) instead of relying on a chi-square approximation, making it more reliable for small sample sizes or tables with low expected cell counts.

About the Fisher's Exact Test

The Fisher's Exact Test Calculator computes the exact two-tailed p-value for a 2x2 contingency table of counts, instead of relying on the chi-square approximation. It is built for situations with small sample sizes or low expected cell counts, where a chi-square test's large-sample assumptions become unreliable. Enter the four cell counts and the calculator returns a p-value drawn directly from the hypergeometric distribution.

How It Works

You enter four non-negative counts arranged in a 2x2 table (row 1/column 1, row 1/column 2, row 2/column 1, row 2/column 2). The calculator holds the row and column totals fixed and asks, among every possible table sharing those same totals, how likely a table at least as extreme as yours would be. It sums the exact hypergeometric probability of every such table, giving a two-tailed p-value for the observed pattern.

For row total R1 = a+b, column total K = a+c, and grand total N = a+b+c+d, the probability of any count x in cell a is P(x) = [R1! (N-R1)! K! (N-K)!] / [N! x! (R1-x)! (K-x)! (N-R1-K+x)!], computed with log-factorials for numerical stability. The two-tailed p-value sums P(x) over every valid x where P(x) is less than or equal to the observed table's probability (within a tiny rounding tolerance), capped at 1.

Formula & Methodology

By hand, first tabulate the four cell counts and their row, column, and grand totals. Then, for every table achievable with those same margins, compute its hypergeometric probability using the factorial formula above. Add together the probabilities of every table that is no more likely than the one you actually observed - that sum is the two-tailed p-value.

Examples

A small pilot study

With counts a=8, b=2, c=3, d=7 (20 total observations), the calculator sums the hypergeometric probabilities of the observed table and every table no more likely than it, returning a two-tailed p-value of about 0.0698 (6.98 percent) - just above the conventional 0.05 significance threshold.

A strongly skewed table

With counts a=9, b=1, c=1, d=9 (20 total observations, evenly split margins), nearly all the ratings cluster on the diagonal. The calculator returns a two-tailed p-value of about 0.0011 (0.11 percent), indicating an association unlikely to have arisen by chance.

Advantages

  • Gives an exact p-value rather than an approximation, remaining valid even when expected cell counts fall below the usual chi-square guideline of 5 per cell.
  • Works directly from raw counts, with no need to verify large-sample assumptions before trusting the result.
  • Handles small or unbalanced 2x2 tables, such as a 20-person pilot study, where a chi-square test could over- or under-state significance.

Common Mistakes

  • Treating a large p-value as proof that no relationship exists, rather than as evidence the data don't provide strong enough support at this sample size.
  • Applying the test to tables larger than 2x2, which this calculator's formula does not accommodate.
  • Entering percentages or rates instead of actual observation counts, which are required for the hypergeometric calculation to be meaningful.

Edge Cases to Watch For

  • All four cell counts must be zero or greater; negative entries are rejected outright.
  • The table must contain at least one observation across all four cells.
  • The valid range of possible counts in cell a runs from max(0, R1-(N-K)) to min(R1, K), covering every table achievable with the same row and column totals.
  • The reported p-value is capped at 1, since summing many small probabilities can occasionally round fractionally above 1.

Common Use Cases

  • Researchers analyzing a small clinical trial or pilot study comparing a binary outcome between two groups.
  • Quality control teams testing whether a defect rate differs between two production batches when sample sizes are limited.
  • Analysts checking the association between two binary survey questions when the respondent count is too small for a reliable chi-square test.
Written & fact-checked by the Calculateus TeamLast updated August 5, 2026How we verify our formulas

Frequently asked questions

Why use Fisher's Exact Test instead of a chi-square test?

The chi-square test relies on a large-sample approximation that becomes unreliable when expected cell counts are small (commonly cited rule of thumb: any expected count under 5). Fisher's Exact Test computes the exact probability directly from the hypergeometric distribution, making it the preferred choice for small 2x2 tables.

Conclusion

Because it calculates probabilities directly from the hypergeometric distribution rather than a large-sample approximation, Fisher's Exact Test Calculator is the more defensible choice whenever a 2x2 table involves small or unevenly distributed counts. Compare the resulting p-value to your chosen significance threshold the same way you would with any other hypothesis test.