Fisher Exact Test Calculator
Many Fisher calculators print one two-sided p-value without saying which definition produced it, and the two definitions in common use disagree. On the twin convictions table, 2 and 10 over 15 and 3, probability ordering gives 0.0005367 while twice the smaller tail gives 0.0009304. This page prints both, names the one the readout leads with, and puts the left tail, the right tail and the sample odds ratio beside them with all four margins. The arithmetic is exact: each table's probability is a whole-number fraction over C(total, column 1), each tail is a sum of those integers, and nothing becomes a floating-point number until the final step. At the 20,000 ceiling an even table has a denominator past 6,000 digits, far outside anything a double can hold, and the p-value still comes back.
col 1 col 2 total row 1 1 9 10 row 2 11 3 14 total 12 12 24 two-sided p 0.0027595 probability ordering left tail p 0.0013797 x <= 1 right tail p 0.9999663 x >= 1 doubled tail 0.0027595 twice the smaller tail odds ratio 0.0303 sample, ad/bc
- Two-sided p
- Left tail p
- Odds ratio
- Ordering
- By probability
Two-sided p, probability ordering = 0.0027595. Right tail p = 0.9999663. The probability of the table exactly as entered is 0.0013461, and these margins allow 11 tables in all.
The two-sided p adds 4 of the 11 tables these margins allow: every table whose probability is at most 0.0013461, the probability of the one you entered. Twice the smaller tail, the other two-sided definition, gives the same number here: 0.0027595.
Your 2 x 2 table
Four counts of observations, one per cell. The margins fill in as you type, and both of them are held fixed: that is what makes the test exact rather than an approximation.
Which p-value to lead with
Both directions at once, by probability ordering: every table no more likely than the one you entered, added up. The other definition in use, twice the smaller tail, is printed underneath so the two can be compared on your own counts.
Worked cases
The three tables this page was built against. Every figure here is computed by the same code as the answer above, so the cases and the tool can never disagree.
Common questions
- How is Fisher's exact test calculated?
- Both margins are held fixed, which leaves one free number: the top-left count. The probability of any table with those margins is C(row 1, x) times C(row 2, column 1 minus x), divided by C(total, column 1). For the table 1 and 9 over 11 and 3, the margins allow 11 tables, the one you entered has probability 0.0013461, and the left tail, every table with a top-left count of 1 or less, comes to 0.0013797. The two-sided p adds the 4 tables no more likely than yours and comes to 0.0027595. Each of those numbers is a fraction of whole numbers here, never a rounded product of factorials.
- Which two-sided p-value does this calculator use?
- Probability ordering: every table these margins allow whose probability is at most the probability of the one you entered, added up. That is the definition R's fisher.test uses by default, and the page names it in the readout so the number is never anonymous. The other definition in circulation doubles the smaller tail, and the page prints that too. On 1 and 9 over 11 and 3 both come to 0.0027595, but on the twin convictions table, 2 and 10 over 15 and 3, probability ordering gives 0.0005367 and the doubled tail gives 0.0009304. Quoting a two-sided p without the definition beside it is how two calculators end up disagreeing.
- What is the lady tasting tea example?
- Fisher's own example: eight cups, four poured milk first and four tea first, and a taster who sorts them into the right two groups. Three of the four placed correctly is the table 3 and 1 over 1 and 3, where the right tail comes to 0.2428571 and the two-sided p by probability ordering comes to 0.4857143. Typing those four counts in prints exactly that, which makes it a quick way to check this page against the textbook.
- What is the difference between Fisher's exact test and a chi-square test?
- Fisher's test computes the exact hypergeometric probability of every table the margins allow, so it does not lean on a large-sample approximation and it is defined even when a cell is 0. A chi-square test compares a statistic against a continuous curve, which is a different calculation with its own assumptions about expected counts, and it is not what this page computes. This page does the exact 2 x 2 test only. The chi-square test calculator is a different page for that different job.
- Why does my software report a different odds ratio?
- This page reports the sample odds ratio, ad/bc, which for 1 and 9 over 11 and 3 is 3 over 99, or 0.0303. Several statistics packages report a conditional maximum likelihood estimate alongside their p-value instead, and that is a different estimator which lands on a different number for the same four counts. The p-value itself does not use the odds ratio at all, so the two are never in conflict. When b or c is 0 the ratio has nothing to divide by and the page says infinite, and when a row or a column is empty it says undefined, rather than printing a number.
- What happens when a row or a column adds up to zero?
- The margins then allow exactly one table, so the observed table is the only one there is and every p-value here is exactly 1. The page says so in the note and shows the odds ratio as undefined, because 0 divided by 0 is not a number. This is the case that makes many calculators return NaN or an empty result. Here it is a stated outcome rather than a failure.
- Does swapping the rows or columns change the p-value?
- The two-sided p does not change. Transposing the table 1 and 9 over 11 and 3 into 1 and 11 over 9 and 3 gives 0.0027595 either way, and the page prints that as one of its worked cases. A one-tailed p is different: reversing the rows turns the left tail into the right tail, which is why both tails are on screen at once and each is labelled with the count it is measured from.
- How large a table can it handle?
- Up to 20,000 observations in total, with each cell up to 20,000. Bigger tables are refused with both numbers rather than trimmed to fit. The limit is speed, not precision: the work grows with the total, while the exact fractions stay exact however large they get. An even table at that ceiling has a denominator with more than 6,000 digits, which is well past the point where a calculator built on floating-point factorials returns Infinity or NaN. A p-value under about 1e-308 is smaller than any number a browser can hold, and the page prints that it is under 1e-308 rather than rounding it to 0.
- Is Fisher's exact test only for small samples?
- It is exact at any size, and small counts are simply where approximations are at their worst, which is why it is usually named there. The reason it is often avoided on larger tables is arithmetic, not statistics: the factorials overflow. Because every probability here is a whole-number ratio, the same exact method runs at a total of 12 and at a total of 20,000.
- What does the p-value here tell me?
- It is the probability, with both margins held fixed and the rows and columns treated as unrelated, of seeing a table at least as unlikely as yours by the ordering named in the readout. It is a description of these four counts and nothing more. This page draws no conclusion from the number, sets no cut-off and offers no reading of what it means for your study.
Exact hypergeometric probabilities summed across tables, computed as whole-number ratios so a large table neither overflows nor rounds on the way to the answer. Two-sided here means the probability-ordering definition, every table no more likely than yours, and the page names it because the competing definitions give different numbers on the same counts. The odds ratio shown is the sample ad/bc. It reports a p-value and interprets nothing.