01
How to use the calculator
- Put your two groups in the rows (for example treatment and control) and the two outcomes in the columns (for example recovered and not recovered).
- Enter the number of subjects in each of the four cells.
- Read the two-sided p value, unless you predicted the direction before collecting the data.
02
When to use Fisher’s exact test
Use it for a 2 × 2 table of counts when any expected count is below 5, which is where the chi-square approximation becomes unreliable. It is valid for any sample size, so it is also a safe choice when you are unsure. The chi-square calculator shows the expected counts and warns when they are too small.
As with chi-square, each subject must be counted once. Paired before-and-after data need McNemar’s test.
03
How the exact p value is calculated
With the row and column totals fixed, the probability of a table with cells a, b, c, d and total n follows the hypergeometric distribution:
p(table) = (a+b)! (c+d)! (a+c)! (b+d)! ÷ (n! a! b! c! d!)
The two-sided p value adds up the probabilities of every possible table that is as probable as the observed one or less. A one-sided p value adds up the tables at least as extreme in one direction.
04
Worked example
The calculator opens with this table:
| Outcome: yes | Outcome: no | |
|---|---|---|
| Group 1 | 3 | 1 |
| Group 2 | 1 | 3 |
With all margins equal to 4, the first cell can be 0, 1, 2, 3 or 4, with probabilities 1/70, 16/70, 36/70, 16/70 and 1/70. The observed table (3) has probability 16/70. Tables that probable or less are those with 0, 1, 3 or 4:
p = (1 + 16 + 16 + 1) ÷ 70 = 0.4857
The one-sided p value (3 or more) is 17/70 = 0.2429, and the odds ratio is (3 × 3) ÷ (1 × 1) = 9. Eight subjects are far too few to show a difference, even with 75% against 25%.
05
The odds ratio
odds ratio = (a × d) ÷ (b × c)
An odds ratio of 1 means the outcome is equally likely in both groups; above 1, more likely in group 1. When b or c is zero the sample odds ratio is infinite, and the calculator shows ∞.
06
Common mistakes with Fisher’s exact test
- Using chi-square on small counts. For the worked example, where every expected count is 2, Pearson’s chi-square gives p = 0.157, three times smaller than the exact 0.486.
- Choosing the one-sided p after seeing the data. It halves the p value: 0.243 instead of 0.486 for the worked example.
- Doubling the one-sided p and calling it two-sided. For the table 6, 1 / 2, 6 the two-sided p is 0.041, but twice the one-sided p is 0.063; say which you report.
- Reading a large p as “no difference”. The worked example’s 75% against 25% gives p = 0.49 with 8 subjects; the same split with 80 subjects (30, 10 / 10, 30) gives p = 0.000015.
Trust
How this page is checked
- The calculation runs on code with automated tests against worked reference values. Every number in the examples on this page was produced by that same code, not typed by hand.
- The formulas and conventions used are stated on the page, so you can reproduce the result yourself or compare it with your own software.
- Last reviewed by the Sciloom team, Zebra Nine Studio Inc. It is a tool for research and teaching, not a substitute for a statistician, a validated lab method or medical advice.
Cite this page
Sciloom. (2026). Fisher’s exact test calculator. Zebra Nine Studio Inc. https://sciloom.si/fishers-exact-test-calculator
Frequently asked questions
When should I use Fisher’s exact test instead of chi-square?
When the table is 2 × 2 and any expected count is below 5. Fisher’s test computes the p value exactly instead of relying on an approximation that fails for small counts.
Is Fisher’s exact test one-tailed or two-tailed?
It can be either. The calculator reports the two-sided p value as the main result and both one-sided values below it.
Can I use Fisher’s exact test with large samples?
Yes. It is valid for any sample size and gives nearly the same answer as chi-square when counts are large.
Does it work for tables larger than 2 × 2?
This calculator handles 2 × 2 tables. For larger tables use the chi-square calculator, merging small categories if expected counts are low.