Connect via MCP →

Enter Calculation

Formula

Show calculation steps (1)
  1. Two-Sided p-Value

    Two-Sided p-Value: Fisher's Exact Test Calculator (2x2)

    Sum of the probabilities of all tables (same margins) that are no more likely than the observed table; p_i is the hypergeometric probability of each possible table

Advertisement

Results

Two-sided p-value
0.034965
Fisher exact test (2x2)
Probability of observed table 0.023601
Total observations (n) 16

What is Fisher's Exact Test?

Fisher exact test assesses whether two categorical variables in a 2x2 contingency table are associated. Unlike the chi-square test, it computes an exact p-value rather than an approximation, making it ideal for small samples or tables with low expected cell counts. It is widely used in biology, medicine, and social science.

2x2 contingency table with cells labeled a, b, c, d and row, column, and grand totals
A 2x2 contingency table showing the four cell counts a, b, c, d with row and column totals.

How to use this calculator

Enter the four cell counts of your 2x2 table: a and b form the first row, c and d form the second row. The calculator computes the exact hypergeometric probability of the observed table and the two-sided p-value, which sums the probabilities of all tables (with the same row and column totals) that are no more likely than the one you observed.

The formula explained

With margins fixed, the probability of any specific table follows the hypergeometric distribution:

$$p = \dfrac{(a+b)!\,(c+d)!\,(a+c)!\,(b+d)!}{n!\;a!\,b!\,c!\,d!}$$

where \(n = a + b + c + d\). The two-sided p-value adds up \(p\) over every table with the same margins whose probability is less than or equal to the observed probability.

$$P_{\text{two-sided}} = \sum_{\,p_i \le p_{\text{obs}}} p_i$$
Advertisement
Hypergeometric probability distribution of table arrangements with the observed value highlighted
Fisher's test sums hypergeometric probabilities of tables as or more extreme than the observed one.

Worked example

For the table \(a = 8\), \(b = 2\), \(c = 1\), \(d = 5\) (\(n = 16\)), the probability of this exact table is about \(0.01865\). Summing all equally-or-less-likely tables gives a two-sided p-value of roughly \(0.0349\), suggesting a statistically significant association at the \(0.05\) level.

FAQ

When should I use Fisher's test instead of chi-square? Use Fisher exact test when sample sizes are small or any expected cell count is below 5, where the chi-square approximation is unreliable.

What does the two-sided p-value mean? It is the probability of obtaining a table at least as extreme as yours in either direction, assuming no association between the variables.

Can the test handle larger tables? This calculator handles 2x2 tables. Larger contingency tables require generalized exact tests.

Last updated: