Fisher's Exact Test
Enumerate tables with fixed margins to compute a two-sided p-value.
Free theory articleEnumerate tables with fixed margins to compute a two-sided p-value.
Concept & interpretation
Fisher's Exact Test examines whether the rows and columns in a 2×2 contingency table are independent. By conditioning on the observed row and column margins, the test considers only tables that preserve these totals. This turns a test of independence into a combinatorial counting problem: what is the chance of seeing a table as extreme as the one observed, among all tables with the same margins?
Experimenting with Constraints
The Fisher's Exact Test explorerallows you to interactively manipulate the four cells of the 2×2 table.
- Start with the default table: set Cell a to 1, Cell b to 9, Cell c to 11, and Cell d to 3. Observe the probability mass chart. The red dashed line marks the observed table, and bars colored teal represent the tables included in the two-sided p-value.
- Change Cell a to 0, Cell b to 2, Cell c to 2, and Cell d to 0. The support narrows significantly to just [0, 2], and the two-sided p-value jumps to 1/3 ≈ 0.333333, with an odds ratio of exactly 0.
- Set all cells to 1. The margins are completely symmetrical, resulting in a support of [0, 2], an odds ratio of 1, and a maximum possible two-sided p-value of 1.
- Set all four cells to
0. There are no observations, so the p-value and odds ratio are undefined. - Keep a and b zero and set c and d to
1. The support is the singleton [0,0], both table probability and p-value are one, while the odds ratio remains undefined.