Quick answer
Fisher's exact test is a significance test for a 2×2 table of counts. It uses the hypergeometric distribution, with row and column totals held fixed, to compute an exact p-value, and is used mainly when samples or expected counts are too small for the chi-square approximation.
Formula: P(table) = C(a + b, a) × C(c + d, c) ÷ C(n, a + c); p = sum over tables no more likely than the observed one
What is Fisher's exact test?
Fisher's exact test is a significance test for a 2×2 table of counts, used to ask whether two yes/no variables are associated, for example version (old or new) and outcome (converted or not). Instead of relying on a large-sample approximation, it computes the probability of the observed table, and of other tables, directly from the hypergeometric distribution.
The calculation treats the row totals and column totals as fixed. Given that so many people saw each version, and so many converted overall, it asks how often chance alone would split the conversions as unevenly as they were split. The null hypothesis is that the true odds ratio equals 1, which is how the SciPy documentation states it.
NIST describes it as an excellent choice when the two independent samples are small. It is valid with large samples too; it is just that approximate tests give nearly the same answer there with less computation.
Worked example: a small conversion table
A new onboarding flow, B, is shown to 16 trial accounts and the old flow, A, to 15 (sample data):
| Flow | Upgraded | Did not upgrade | Total | Upgrade rate |
|---|---|---|---|---|
| B (new) | 6 | 10 | 16 | 37.5% |
| A (old) | 1 | 14 | 15 | 6.7% |
| Total | 7 | 24 | 31 | 22.6% |
If flow made no difference, the 7 upgrades would be spread over the two groups like 7 names drawn from 31, of whom 16 saw B. The probability that exactly x of the upgrades land in B is
P(x) = C(16, x) × C(15, 7 − x) ÷ C(31, 7), with C(31, 7) = 2,629,575.
| Upgrades in B (x) | Probability | As unlikely as the observed table or more? |
|---|---|---|
| 0 | 0.0024 | Yes |
| 1 | 0.0304 | Yes |
| 2 | 0.1370 | No |
| 3 | 0.2907 | No |
| 4 | 0.3149 | No |
| 5 | 0.1744 | No |
| 6 (observed) | 0.0457 | Yes |
| 7 | 0.0043 | Yes |
Two-sided p-value: add the probabilities of all tables no more likely than the observed one: 0.0024 + 0.0304 + 0.0457 + 0.0043 ≈ 0.083.
One-sided p-value (only "B is better"): P(6) + P(7) ≈ 0.0500, in fact 0.05003, a hair above 0.05.
A rate that is more than five times higher still does not clear a two-sided 0.05 threshold, because 7 upgrades in total carry little information. Choosing the one-sided figure after seeing that B came out ahead would not rescue it, and would not be a fair test anyway: the direction has to be fixed, with a reason, before any account enters the flow. The sample odds ratio is (6 × 14) ÷ (10 × 1) = 8.4, with a great deal of uncertainty around it.
Fisher's exact test vs chi-square test
The chi-square test compares observed with expected counts and refers the result to a smooth curve. Here the expected counts are small: upgrades expected in B are 16 × 7 ÷ 31 = 3.61 and in A 15 × 7 ÷ 31 = 3.39. Both are below 5, the traditional point at which the approximation is questioned. The same table gives:
| Test | Statistic | Two-sided p | Verdict at 0.05 |
|---|---|---|---|
| Pearson chi-square | 4.21 | 0.040 | Passes |
| N−1 chi-square | 4.07 | 0.044 | Passes |
| Chi-square with Yates' correction | 2.63 | 0.105 | Does not pass |
| Fisher's exact test | none needed | 0.083 | Does not pass |
One table, four tests, and two different verdicts. That is a warning about the data more than about the formulas.
Which to use? The textbook rule is chi-square when every expected count is at least 5, otherwise Fisher. Ian Campbell's 2007 simulation study of small 2×2 tables repeats Cochran's own remark that the number 5 was chosen arbitrarily, and found the best policy to be the N−1 chi-square test whenever the smallest expected count is at least 1, with the Fisher-Irwin test below that. Fisher's test tends to be conservative: its true false-alarm rate is usually below the nominal 5%. Both positions are defensible. Decide which test you will use before seeing the results, and write it down.
How fragile a small result is
Move one outcome and look again. If one more B account had upgraded (7 of 16 against 1 of 15), Fisher's two-sided p-value would fall from 0.083 to about 0.037.
A conclusion that flips with one customer is not ready to act on. Practical responses:
- Report the counts, not only the percentages: "6 of 16 against 1 of 15".
- Show an interval for each rate or for the difference.
- Keep collecting until a sample size chosen in advance is reached; see sample size and statistical power.
- Do not peek daily and stop at the first p below 0.05.
When to use it and when not
| Situation | Choice |
|---|---|
| 2×2 table, some expected count below 5 | Fisher's exact test (or N−1 chi-square, chosen in advance) |
| 2×2 table, large counts | Chi-square or two-proportion z test |
| Same people measured twice, yes/no | McNemar's test |
| More than two groups or outcomes | Chi-square, or an exact extension in statistical software |
| Revenue or time instead of yes/no | A test for numeric data, not a 2×2 table |
Conditions still apply. Each account must appear in one cell only, and accounts must be independent. Ten users from the same company who upgrade together are closer to one observation than to ten. And without random assignment, a small p-value describes an association, not an effect of the flow. The full decision table is in which statistical test.
If you run Fisher's test on many segments, adjust the threshold; see the Bonferroni correction example.
Running it, with counts from TapCub
In software it is one line: scipy.stats.fisher_exact([[6, 10], [1, 14]]) in Python, or fisher.test in R. Note that different packages report the odds ratio estimated in different ways; SciPy's documentation says its estimate differs from R's.
TapCub does not run A/B tests or compute this test. It can provide the four counts:
- Tag the flow. Send the assigned flow as an event property on the trial and upgrade events, from your own assignment logic.
- Count people. In All-platform analytics › Behavior › Event analysis, take unique people for the trial event and the upgrade event and break them down by the flow property. "Did not upgrade" is trials minus upgrades.
- Check identity. The default identity is visitor; for account flows switch to the identity that matches your randomization unit, so one customer is not counted twice.
- Treat chat comparisons with care. Live chat › Reports › Conversion attribution warns when fewer than 30 visitors chatted. A Fisher test on such counts can describe the gap, but visitors chose whether to chat, so it cannot show that chat caused it.
Sources
- NIST/SEMATECH e-Handbook of Statistical Methods, 7.3.3 How can we determine whether two processes produce the same proportion of defectives? (exact test for small samples).
- SciPy documentation, scipy.stats.fisher_exact (null hypothesis, two-sided p-value, odds ratio estimate).
- Campbell, I. (2007). Chi-squared and Fisher-Irwin tests of two-by-two tables with small sample recommendations. Statistics in Medicine, 26(19), 3661–3675.
Was this explanation clear?
We use your answers to fix and expand this page.
Couldn’t send. Please try again in a minute.
Thanks for the feedback. We’ll use it to improve this page.You’ve already sent feedback on this page. Thanks.

Data Engineer
Writes about event design, data quality, and collection workflows, with verifiable implementation methods for reliable analytics.