statcompute

Hypothesis tests

Fisher's Exact Test Calculator

Test a 2×2 table exactly, by enumerating every table with the same margins — the right test when the counts are too small for chi-square.

Also called fisher exact test calculator, Fisher exact calculator, Fisher-Irwin test calculator.

Updated August 2026Runs in your browser — nothing is uploadedVerified against R
Two-sided is the default and the usual choice.
Conventionally 0.05. Decide before you look at the data.

The calculation runs in your browser, so this box needs JavaScript. The formula, the worked example and the interpretation below do not.

01

How to read this result

"Exact" is literal. With the row and column totals held fixed, only a handful of tables are possible. The test computes the probability of each one under the null hypothesis, and adds up the probabilities of every table at least as unlikely as yours. That sum is the p-value — no distribution is being approximated, so there is no minimum count and no expected-frequency rule.

The two-sided p-value is not double the one-sided one. It is the total probability of all tables no more likely than the observed one, which is the definition R uses and the one shown here. Doubling the smaller tail is a different convention that can give a slightly different answer; the table of every possible outcome above shows exactly which tables were included.

Two odds ratios are reported, and they differ. The sample odds ratio (a·d/b·c) is the obvious one. The conditional maximum-likelihood estimate is the one that belongs with an exact test, and it is what R's fisher.test reports; with small counts the two can differ by a lot.

The confidence interval is usually enormous. That is not a defect — it is the honest width for a table with single-digit cells. An interval running from 1.4 to 1039 says the direction is established and the magnitude is not.

02

The formula

P=(a+ba)(c+dc)(na+c)
a,b,c,d
the four cell counts
n
the total, a + b + c + d

The hypergeometric probability of one particular table, given the margins. The two-sided p-value is the sum of this over every table whose probability is no greater than the observed table's. Computed in log space, so a table with hundreds of observations does not overflow.

03

Worked example

A pilot study with ten subjects per arm

A pilot trial of a new procedure: 10 subjects receive it and 9 succeed; 10 receive the standard procedure and 3 succeed. The numbers are tiny — two of the four expected counts are 4, below the 5 that the χ² approximation asks for. Fisher's exact test needs no such assumption.

successfailure
new91
standard37
  1. Fix the margins: rows 10 and 10, columns 12 successes and 8 failures.
    only 9 tables are possible, with cell a running from 2 to 10
  2. Compute the hypergeometric probability of each one.
    P(a) = C(10,a)·C(10,12−a) / C(20,12)
  3. The observed table has a = 9.
    P(9) = 0.00953
  4. Add the probability of every table no more likely than that one — here a = 9, a = 10 on one side and a = 3, a = 2 on the other.
    p = 0.00953 + 0.00036 + 0.00953 + 0.00036 ≈ 0.0198
  5. The odds ratio, by conditional maximum likelihood.
    OR = 17.3
two-sided p 0.0198odds ratio 17.395% CI 1.39 to 1039one-sided p 0.0099

Significant, and almost uninformative about size: the interval spans a factor of 750. That is the honest reading of twenty subjects, and it is why pilot studies establish feasibility rather than effect size.

Checked against R's fisher.test.

The calculator above is loaded with these numbers by the Load the worked example button.

04

Assumptions, and when to use something else

Fisher's exact test assumes independent observations and — this is the subtle one — it conditions on both margins being fixed. In the original tea-tasting experiment they genuinely were: the taster knew there were four cups of each kind. In most real studies only the row totals are fixed by design, and conditioning on the column totals as well makes the test somewhat conservative: its true false-positive rate is below the nominal α.

That conservatism is the price of exactness, and it is why the test is preferred for small counts but not for large ones, where chi-square is both adequate and more powerful.

  • The table is larger than 2×2Chi-square testThe r × c exact test is a much larger computation and is not implemented here; chi-square handles any table shape.
  • Expected counts are comfortably above 5Chi-square testWith adequate counts, chi-square gives essentially the same answer with more power.
  • The same subjects measured twiceMcNemar's testPaired data needs a paired test; Fisher's assumes the two rows are independent groups.
  • You want the risk ratio rather than the odds ratioRelative riskWhen the rows are the exposure groups and the outcome is common, relative risk is the more interpretable summary.
05

Questions people ask

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

Whenever any expected count falls below about 5 in a 2×2 table. Many statisticians now use it for every 2×2 table regardless, since it is exact and computers make the cost irrelevant. Chi-square keeps the advantage for larger tables, where the exact computation becomes expensive.

Why is my odds ratio different from a·d ÷ b·c?

Because the calculator reports the conditional maximum-likelihood estimate as well as the plain sample ratio. The conditional estimate is the one consistent with the exact test's conditioning on the margins, it is what R reports, and with small counts the two genuinely differ. Both are shown.

Can I use Fisher's exact test on a 3×2 table?

Not here. The exact test generalises to r × c tables — R's fisher.test will do it — but the enumeration grows quickly and it is not implemented on this page. For a 3×2 table with adequate counts, use chi-square.

What does a zero cell do to the test?

Nothing at all — Fisher's test handles zeros without complaint, which is one of its advantages. It is the odds ratio that becomes 0 or infinite, and the interval on it then runs to a boundary.