# Fisher's exact test - how to find tables "as extreme"

I attempted to understand the computation of the Fisher's exact test through programming using this formulation:

The Fisher exact test computes the p-values by finding the probabilities of all possible combinations of 2 × 2 tables that have the same marginal totals (the values in cells m, n, r, and s) that are equal to or more extreme that the ones observed.

Via enumeration of all different cell numbers, I can calculate the first part of the above formulation. This allows me to find all tables which have the same marginal totals. However, I encounter a problem with the second part, which involves finding equal or more extreme cases.

Test table:

A B $$\sum$$
C 8 7 15
D 11 3 14
$$\sum$$ 19 10 29

The number of tables with the same marginal totals is 11, including the above case.

$$c_{1,1}$$ $$c_{1,2}$$ $$c_{2,1}$$ $$c_{2,2}$$
5 10 14 0
6 9 13 1
7 8 12 2
8 7 11 3
9 6 10 4
10 5 9 5
11 4 8 6
12 3 7 7
13 2 6 8
14 1 5 9
15 0 4 10

Which of these are equal or more extreme? How can I identify them?

• Good question. There's only one sensible answer for a one-tailed test - that is various sensible criteria all lead to the same answer -, but quite a few for a two-tailed test. Your choice might depend somewhat on the model for how the data are generated - e.g. comparing two binomial samples. Commented Mar 31 at 14:11