Fisher Exact Test Calculator for Sparse 2×2 Tables
Enter four frequency counts, choose a one-sided or two-sided test, and see exactly which fixed-margin tables contribute to the p-value. Compare the exact fraction against a threshold and see how Pearson’s approximation behaves with small expected counts.
Test a sparse 2×2 table with exact probabilities
Compare the observed counts to every possible table with the same margins.
Observed counts and test rule
Use independent observations in four mutually exclusive cells. Each row and column needs a positive total.
Exact p-value is above the threshold.
Exact and approximate results
Includes tables with probability at most that of the observed table.
- Fisher exact p-value
- 1/7
- Decimal 0.142857
- Tables counted
- 2 / 4
- Same observed margins
- Pearson approximate p-value
- 0.0284597
- χ² = 4.8 · 1 degree of freedom
- Expected cells below 5
- 4 / 4
- Smallest expected count 1.5
Sparse expected counts can make the Pearson approximation unreliable.
Inspect the table behind each bar
Linear scale · tallest bar 0.428571
- Inspected counts in table order
- 0, 3, 4, 1
- Exact probability of this table
- 1/14
Included in the p-value.
Export all fixed-margin tables
The CSV includes exact integer weights over a common denominator, selected-tail membership, and the Pearson comparison.
View CSV text
How to use this calculator
- Enter four nonnegative whole frequency counts in two rows and two columns. Every row and column must have a positive total and the combined count may be at most 1,000.
- Choose the alternative and enter a decimal threshold between 0 and 1. The comparison treats p equal to the threshold as at or below it.
- Read the exact Fisher value alongside the separate Pearson approximation. Use the slider to reconstruct each possible table and check which outcomes enter the selected tail.
- Switch to the log scale when rare tables are hard to distinguish. Download all exact integer weights and tail membership or select the matching CSV text.
The Formula
The mathematical logic powering this calculation is:
Under conditional independence and the observed row and column totals, top-left count X follows a central hypergeometric distribution. Let R be the first row total, C the first column total and N the grand total. Then P(X=x) = choose(C,x) × choose(N−C,R−x) / choose(N,R), where max(0,R−(N−C)) ≤ x ≤ min(R,C).
The lower and upper tails include X≤observed and X≥observed, respectively. The probability-ordered two-sided tail counts every table whose probability is no greater than that of the observed table, including tied probabilities. Integer probabilities share one denominator, so tail membership and the threshold comparison use exact arithmetic.
Pearson’s approximate comparison uses χ² = Σ(O−E)²/E with one degree of freedom and E given by the product of the corresponding row and column totals divided by N. The workspace flags small expected counts and applies no continuity correction.Worked Example
If you input:
- Group A: 0, 3
- Group B: 4, 1
- Test and threshold: Two-sided, 0.05
Result:
Two of four possible tables contribute. The exact two-sided p-value is 1/7, about 0.142857. Pearson χ² is 4.8 and its approximate p-value is about 0.0284597. All four expected counts are below 5.
Frequently Asked Questions
Does a two-sided Fisher p-value double the smaller tail?
This workspace uses probability ordering. It adds probabilities of all tables at least as rare as the observed one, including exact ties. An asymmetric fixed-margin distribution can give a different value from doubling the smaller inclusive tail.
Why can the exact and Pearson p-values disagree?
Fisher’s test conditions on the observed margins and sums probabilities over a discrete set of possible tables. The Pearson comparison uses a continuous large-sample approximation, which can be poor with sparse expected counts.
What counts can I enter?
Use counts of independent observations, one cell per observation. The calculation assumes a 2×2 table with positive margins. Individual cells can be zero. Paired observations and weighted percentages require a different model.
What does the threshold comparison tell me?
It shows whether the exact p-value is at or below your chosen threshold for the selected alternative. Choose the threshold and the direction before seeing the data when using them for inference. A p-value does not quantify the size of the association.
Similar Calculators
Chi-Square Test Calculator
Compare categorical counts with chi-square independence or goodness-of-fit tests. Inspect expected counts, residuals, contributions, sparse-count warnings and CSV results.
Relative Risk Quick Calculator
Compare event risk in an exposed group versus a control group.
Binomial Probability Calculator
Find exact, cumulative, or upper-tail binomial probabilities for repeated yes/no events.
McNemar Test Calculator for Paired Binary Outcomes
Compare paired binary outcomes with exact McNemar and mid-p tests. Plot the conditional tail and see the change in percentage points.
