Fisher's Exact Test Calculator

Enter the four counts of a 2×2 table to get the exact two-sided and one-sided p-values, the odds ratio with its 95% confidence interval, and a ready-to-copy APA 7 sentence. Built for small samples where the chi-square test is unreliable, and computed entirely in your browser.

Results
StatisticValue
p-value0.054
Left tail0.995
Right tail0.027
OR4.50
95% CI OR[1.17, 17.37]

APA report

Fisher's exact test, p = p = .054, OR = 4.50

Have full study data?

Upload your dataset and generate a complete paper draft with statistics, figures, and references—free preview.

Generate paper

How to use the Fisher exact test calculator

1. **Enter the 2×2 table.** Type the four cell counts (a, b, c, d), or paste raw data / load a CSV with two binary variables and let the calculator cross-tabulate them. 2. **Label rows and columns** (for example Treatment / Control and Improved / Not improved) so the output and the APA sentence read correctly. 3. **Read the p-values.** You get the exact two-sided p-value and both one-sided p-values. Use the one-sided value only if you specified the direction before seeing the data. 4. **Read the odds ratio** and its 95% confidence interval. 5. **Copy the APA 7 sentence.**

The calculation runs locally in your browser; the counts you enter are not sent anywhere.

What Fisher's exact test does and when to use it

Fisher's exact test checks whether two binary variables are associated — for example, whether the proportion of patients who improve differs between a treatment and a control group.

Unlike the chi-square test, it does not rely on a large-sample approximation. It treats the row and column totals as fixed and computes, from the hypergeometric distribution, the exact probability of every table that could have occurred with those totals. The p-value is the total probability of tables at least as extreme as the one observed.

Use it when:

  • you have a **2×2 table** of counts;
  • the sample is **small**, or any **expected** cell count is below 5 (the usual rule for when the [chi-square test](/tools/chi-square-calculator) becomes unreliable);
  • the data are rare events, such as adverse effects in a small trial.

With large samples Fisher's test and the chi-square test give similar answers; Fisher's is still valid, just more computationally demanding.

Assumptions

  • **Independent observations:** each subject is counted in exactly one cell. Paired data (the same people before and after) need McNemar's test instead.
  • **Two binary variables**, giving a 2×2 table of counts — not percentages, means or rates.
  • **Fixed margins:** the test conditions on the row and column totals. In practice it is widely used even when only one margin was fixed by design, which makes it somewhat conservative.

There is no minimum sample size: that is the point of an exact test.

Formula

Label the table:

| | Outcome yes | Outcome no | Total | |---|---|---|---| | Group 1 | a | b | a + b | | Group 2 | c | d | c + d | | Total | a + c | b + d | n |

The probability of a particular table, given the margins, is hypergeometric:

`P = [ (a+b)! (c+d)! (a+c)! (b+d)! ] / [ a! b! c! d! n! ]`

**One-sided p-value:** sum P over the observed table and all tables more extreme in the hypothesised direction.

**Two-sided p-value:** sum P over all tables whose probability is less than or equal to that of the observed table (the standard method used by R and SciPy).

**Sample odds ratio:** `OR = (a · d) / (b · c)`

**95% CI (Woolf / log method):** `exp[ ln(OR) ± 1.96 · √(1/a + 1/b + 1/c + 1/d) ]`

If any cell is zero, the sample OR is 0 or infinite and the log interval needs a correction (commonly adding 0.5 to every cell).

Worked example

In a small pilot study, 10 patients receive a new treatment and 10 receive the standard one:

| | Improved | Not improved | Total | |---|---|---|---| | New treatment | 9 | 1 | 10 | | Standard | 3 | 7 | 10 | | Total | 12 | 8 | 20 |

The expected count for the "Not improved" cells is 4, below 5, so Fisher's exact test is the appropriate choice.

Results (verified with Python and SciPy):

  • **Two-sided p = .020** (0.0198)
  • One-sided p (new treatment better) = .0099
  • **Odds ratio = 21.0**, 95% CI (Woolf) **[1.78, 248.11]**

The odds of improvement were 21 times higher with the new treatment (9:1 versus 3:7). The confidence interval is extremely wide because there are only 20 patients and one cell contains a single count: the data are consistent with anything from a modest to an enormous effect.

For comparison, a Pearson chi-square test without continuity correction would give χ²(1) = 7.50, p = .006 — noticeably smaller than the exact p, which illustrates why the approximation is unreliable at this sample size.

Note that R's `fisher.test()` reports a different odds ratio, the conditional maximum likelihood estimate (here 17.27, exact 95% CI [1.39, 1047.84]). Both are legitimate; say which one you report.

Interpreting the results

  • **p-value:** the probability, under the null hypothesis of no association and with the margins fixed, of a table at least as extreme as yours. Here p = .020, so at α = .05 there is evidence that improvement rates differ.
  • **Two-sided vs one-sided:** the two-sided p is the default. A one-sided test is only justified if the direction was pre-specified, and it cannot be used to rescue a non-significant two-sided result.
  • **Odds ratio:** OR > 1 means higher odds of the outcome in the first row; OR < 1 means lower; OR = 1 means no association. A CI that excludes 1 agrees with a significant result.
  • **Width of the CI:** with small samples it is often very wide. Report it so readers can see how precise the estimate is.
  • **Fisher's test is conservative:** because the p-value moves in discrete steps, the actual false-positive rate is usually below the nominal α.

If you also want relative risk or risk difference, use the [odds ratio calculator](/tools/odds-ratio-calculator).

Reporting Fisher's exact test in APA 7 style

Name the test, give the counts or percentages per group, the exact p-value and the odds ratio with its CI:

> Improvement was more common with the new treatment (9 of 10, 90%) than with standard care (3 of 10, 30%). Fisher's exact test indicated a significant association, *p* = .020 (two-sided), *OR* = 21.0, 95% CI [1.78, 248.11].

There is no test statistic or degrees of freedom to report. State whether the p-value is two-sided or one-sided.

If this table is one piece of a larger dataset you are writing up, Data2Paper's [Generate Paper](/generate-paper) can run all the analyses from your CSV or Excel file and draft the full paper, with a free preview of the first half.

Common mistakes

  • **Applying the "expected count below 5" rule to observed counts.** The rule concerns expected counts, computed from the margins.
  • **Entering percentages instead of counts.** The test needs raw frequencies.
  • **Using Fisher's test on paired data.** Use McNemar's test for before/after on the same subjects.
  • **Switching to a one-sided p after seeing the data** to get below .05.
  • **Reporting only p** without the odds ratio, the group proportions and the CI.
  • **Calling an odds ratio a risk ratio.** When the outcome is common, OR can be much larger than the relative risk (here RR = 0.9 / 0.3 = 3.0, while OR = 21.0).
  • **Reading a non-significant result as proof of no effect** in a small sample; check the confidence interval.

FAQ

Related calculators