Skip to content
MoneyDeck

Fisher’s Exact Test Calculator

Exact two-sided and one-sided p-values for any 2×2 table

Updated · Free, no signup

e.g. treatment group, success

e.g. treatment group, failure

e.g. control group, success

e.g. control group, failure

Two-tailed p-value

0.034965

Right-tailed p-value (positive association, a larger)

0.024476

Left-tailed p-value (negative association, a smaller)

0.999126

Probability of the observed table

0.023601

Sample odds ratio (ad ÷ bc)

20

Total count (N)

16

Decision (two-tailed)

Reject H₀ (no association) at α = 0.05 (p = 0.035)
  • Row totals 10 and 6, column totals 9 and 7: cell a can range from 3 to 9. Your table (a = 8) has probability 0.023601.
  • Two-tailed p = 0.035; one-tailed p = 0.0245 in the direction observed.
  • The association between rows and columns is statistically significant.

Probability of each possible value of a (same margins)

All tables with the same margins

abcdProbability
37600.01049As or more extreme
46510.11014
55420.33042
64330.367133
73240.157343
82150.023601Observed
91060.000874As or more extreme

About the Fisher’s Exact Test Calculator

This Fisher’s exact test calculator tests whether two categorical variables in a 2×2 table are associated, without relying on large-sample approximations. Enter the four cell counts and it returns the exact two-tailed p-value, both one-tailed p-values, the probability of your exact table, the sample odds ratio and a decision at your chosen significance level, plus the full hypergeometric distribution of every table with the same row and column totals.

Fisher’s test is the standard choice when samples are small or expected counts fall below 5 — situations where the chi-square test is unreliable. Researchers use it for pilot studies, clinical case series, A/B tests with few conversions and genetics, and students meet it through R. A. Fisher’s famous “lady tasting tea” experiment.

The test conditions on the row and column totals. The two-tailed p-value adds the probabilities of all tables that are no more likely than the one observed — the method used by R’s fisher.test, SciPy and SAS — so it can differ slightly from software that simply doubles the one-tailed value.

With the default inputs, the two-tailed p-value is 0.034965. Change any value above to recalculate instantly.

How to use the fisher’s exact test calculator

  1. 1Arrange your data as a 2×2 table — groups in rows, outcomes in columns.
  2. 2Enter the four counts a, b, c and d.
  3. 3Choose the significance level.
  4. 4Read the two-tailed p-value, or a one-tailed p-value if you specified a direction in advance.
  5. 5Check the distribution table to see which tables count as “as or more extreme”.

Formula and method

P(a) = C(a+b, a) · C(c+d, c) ÷ C(n, a+c) = (a+b)!(c+d)!(a+c)!(b+d)! ÷ (a! b! c! d! n!)

With all row and column totals fixed, the count in cell a follows a hypergeometric distribution, so the exact probability of any table can be written down with factorials. The calculator evaluates every table that shares your margins (using log-factorials to avoid overflow) and adds up the relevant probabilities.

The right-tailed p-value sums tables with a at least as large as observed (stronger positive association), the left-tailed p-value sums tables with a as small or smaller, and the two-tailed p-value sums every table whose probability is less than or equal to that of the observed table (with a tiny relative tolerance for rounding). This is the conditional exact test described by R. A. Fisher and implemented in R, SciPy and SAS.

a, b, c, d
Cell counts of the 2×2 table
n
Total count a + b + c + d
C(n, k)
Binomial coefficient, n choose k
!
Factorial

Worked examples

Small treatment trial: 8 of 10 vs. 1 of 6

Eight of 10 treated patients improved versus 1 of 6 controls. Holding the margins fixed, the probability of exactly this table is 0.0236. Adding every table no more likely gives a two-tailed p-value of 0.035, so the difference is significant at the 5% level; the sample odds ratio is (8 × 5) ÷ (2 × 1) = 20.

The lady tasting tea (3 of 4 correct)

In Fisher’s tea-tasting design a taster must pick the 4 milk-first cups out of 8. Suppose she gets 3 of 4 right. There are C(8, 4) = 70 ways to choose 4 cups, and 16 give exactly 3 correct, so P = 16/70 = 0.2286. The one-tailed p-value (3 or 4 correct) is 17/70 = 0.243 — not enough evidence for her claim; only a perfect 4 of 4 (p = 1/70 ≈ 0.014) would be.

Strong negative association

Only 1 of 10 in the first group has the outcome versus 11 of 14 in the second. The left-tailed p-value is 0.0014 and the two-tailed p-value is 0.0028, strong evidence of an association, with the outcome much less common in the first group.

Frequently asked questions

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

Use Fisher’s exact test when the sample is small — a common rule is when any expected cell count is below 5 or the total is under about 40. The chi-square test relies on a large-sample approximation that can give misleading p-values in that situation, while Fisher’s test computes the probability exactly.

How is the two-tailed p-value calculated in Fisher’s exact test?+

It adds the probabilities of every table with the same margins whose probability is less than or equal to the probability of the observed table. This is the method used by R, SciPy and most packages. Some older texts double the one-tailed p-value instead, which can give a slightly different answer.

What are the assumptions of Fisher’s exact test?+

Observations must be independent and each must fall into exactly one cell. The test treats the row and column totals as fixed. It does not require large expected counts, which is its main advantage over the chi-square test, but it can be conservative when margins were not actually fixed by design.

Can Fisher’s exact test be used for large samples?+

Yes. It is exact for any sample size, and modern computers handle tables with thousands of observations easily. With large samples the result will closely match the chi-square test, which is why chi-square is often used there for convenience.

What does the odds ratio mean in a Fisher test?+

The sample odds ratio ad ÷ bc measures the strength and direction of the association: above 1 means the column-1 outcome is more likely in row 1, below 1 means less likely. R reports a conditional maximum-likelihood odds ratio, which can differ slightly from the simple sample odds ratio shown here.

Related tools