Fisher Exact Test Calculator

Enter the four cell counts of your 2x2 table to get the exact probability.

How it is calculated

Enter the four counts of a 2×2 table: a and b in the first row, c and d in the second. With the row and column totals held fixed, the tool computes the hypergeometric probability of exactly this table: P = (a+b)! (c+d)! (a+c)! (b+d)! ÷ (a! b! c! d! n!), where n = a+b+c+d. Factorials are handled through logarithms, so larger tables do not overflow. It also shows the total n and the odds ratio (a×d) ÷ (b×c), displayed as ∞ when b×c is zero. All four cells must be whole numbers of at least zero, and the table must not be empty or have a total above 10,000,000 (no result). The first result is the two-sided p-value of the Fisher test: it adds P for this table and for every table with the same totals that is equally or more unlikely. The point probability is shown separately.

Worked example

A small trial: 8 of 10 treated patients improve (a = 8, b = 2) and 1 of 6 untreated patients improves (c = 1, d = 5). Total n = 16 and the column totals are 9 improved and 7 not improved. The probability of exactly this table is (45 × 6) ÷ 11,440 = 0.023601, which is the tool's 0.023601. The odds ratio is (8 × 5) ÷ (2 × 1) = 20.0000. The more extreme table (9, 1, 0, 6) has probability 0.000874, and the tables at the other end add a little more, so the two-sided p-value the tool shows first is 0.034965.

Try this example →

Common mistakes

  • Reading the point probability as the p-value of the test. It is the probability of this single table only; use the two-sided p-value above it.
  • Entering percentages or rates. The cells must be raw counts, such as 8 patients and not 80%.
  • Entering a decimal or negative count. Only whole numbers of zero or above are accepted, and anything else returns no result.
  • Mixing up the layout. Keep groups in rows and outcomes in columns; swapping the two columns (a with b, c with d) leaves the probability unchanged but turns the odds ratio 20 into its reciprocal 0.05.
  • Misreading ∞ as an error. It appears when b × c is zero, meaning one of those cells is empty and the odds ratio cannot be calculated.

About this calculator

The Fisher exact test computes the exact probability of observing a particular 2×2 contingency table of counts, given the table’s fixed row and column totals, rather than relying on the chi-square test’s large-sample approximation. For a table with cells a, b, c, d (and totals n = a+b+c+d), the exact hypergeometric point probability of that specific table is P = [(a+b)!(c+d)!(a+c)!(b+d)!] / [a!·b!·c!·d!·n!], derived from the hypergeometric distribution that describes how counts fall into cells when the margins are held fixed.

This point probability is the building block of the full Fisher exact test p-value (which sums this quantity over all tables as extreme or more extreme than the one observed), and it’s paired here with the odds ratio — (a·d)/(b·c) — which measures the strength and direction of the association between the two categorical variables. Biostatisticians and researchers reach for Fisher’s exact test instead of chi-square specifically when sample sizes are small or any expected cell count falls below about 5, a very common situation in clinical trials, case-control studies, and rare-event data; this calculator returns the two-sided p-value and the exact probability of the entered 2×2 table, along with its total and odds ratio.

Was this helpful?

You can pick up to 3 reactions.

Comments (1)

  • Editorial team

    Fisher's method earns its place when counts are small, for example when an expected cell count falls below 5 and a chi-square test becomes unreliable. The 2×2 table 8, 2, 1, 5 gives a two-sided p-value of 0.034965, a table probability of 0.023601 and an odds ratio of 20.0000, while 9, 1, 0, 6 gives 0.000874 with an odds ratio shown as ∞. What counts are you testing, and did you decide on one-sided or two-sided before looking?

Popular calculators

All Calculators