What is tested
The test requires nonnegative integer cell counts from independent observational units. Its null distribution conditions on observed margins; for a 2×2 table, H0 corresponds to population odds ratio 1. Paired repeated measurements are not automatically covered. Here two-sided means probability ordering exclusively, without a mid-p adjustment. For computational scope, the calculator limits total count to 1 through 200 and explicitly treats empty marginal groups as uninformative.[1][2]
The hypergeometric distribution supplies the conditional count probabilities. A chi-square test instead uses an asymptotic reference and is not the same calculation. When many tables are tested together, a strategy such as the Benjamini–Hochberg procedure is an additional consideration; it does not change the single-test mass defined here.
From margins to the exact sum
With fixed margins, one cell determines the entire table. Under H0, all selections of a first-row group of the given size from the pooled population are equally likely. The two binomial coefficients count selections containing x observations from column one and n−x from column two. This combinatorial argument establishes a conditional probability model, not a biological causal mechanism.[1][2]
- Arrange the table as [[a,b],[c,d]] and fix the meaning of rows and columns. Calculate N=a+b+c+d, K=a+c and n=a+b.
- Fixed margins permit only T(x)=[[x,n−x],[K−x,N−K−n+x]]. Nonnegative cells require max(0,K+n−N)≤x≤min(K,n).
- Under H0, P(T(x))=C(K,x)C(N−K,n−x)/C(N,n). Calculate the observed mass at x=a; every table shares the same combinatorial denominator.
- For a two-sided probability-ordering test, sum every mass≤P(T(a)), including ties. For a one-sided test, instead sum X≤a or X≥a in the direction specified in advance.
See which tables are summed
Which tables contribute to the two-sided p-value?
Free with a Quanta account. Your download stays ready after registration.
Two complete worked examples
Enumerate an asymmetric null distribution
- Given
- Author model: two independent groups give [[1,4],[5,3]]. Columns mean characteristic present or absent.
- Find
- Distinguish observed table mass from the two-sided p-value.
N=13, K=6 and n=5. Feasible upper-left counts are x=0,…,5.
Integer numerator weights for x=0,…,5 are 21,210,525,420,105,6. They sum to 1287.
The two-sided result includes x=0,1,4,5 because their weights are at most 210. The central tables x=2,3 are excluded.
Result: p2≈0.265734 exceeds observed table mass≈0.163170. At α=0.05, the two-sided test does not reject H0.
Check: The lower one-sided value is 231/1287=7/39. Doubling it gives 14/39≈0.358974, explicitly different from the chosen two-sided result.
A direction specified in advance matters
- Given
- Author model: [[5,1],[1,5]], independent groups. Compare a prespecified odds-ratio>1 alternative with the two-sided test.
- Find
- Sum discrete tails with equal-probability tables.
N=12, K=n=6. Weights for x=0,…,6 are 1,36,225,400,225,36,1; denominator is 924.
For the directional alternative sum x≥5. The observed table remains included in the tail.
Probability ordering also includes equally rare tables at x=0,1 in the two-sided test.
Result: At α=0.05, only the justified prespecified directional test crosses the threshold. The direction must not be chosen after inspecting these numbers.
Check: Swapping rows reverses the one-sided direction but leaves the two-sided value unchanged. A p-value does not quantify effect size.
Recall the method later with the formula’s flashcards.
11 flashcards · English materials
Already have an account? Sign in for flashcardsAvailable from Essential. A ready-made formula set, no AI credits required. Article exercises are not all included.
Interpretation and limits
All inputs are counts; all outputs of this calculator are dimensionless probabilities. Percentages without the actual sample size must not be entered as a count table. Zero cells in the first exercise are allowed; fractional observation weights or percentages are not supported by this mode.
Exactness guarantees neither high power nor an unbiased observational study. Discrete p-values can be conservative. Ordering, directional alternative and two-sided convention belong in the analysis plan. Neither observed mass alone nor a favorable tail chosen afterward replaces the defined test. A wholly zero table contains no data; empty margins leave only one feasible table.
Five paths to reliable application
Calculate · Foundation
For [[2,0],[0,2]], calculate the probability-ordering two-sided Fisher p-value.
Show hint
Feasible cell values are 0,1,2; numerator weights are 1,4,1.
Learning goal: Sum an exact two-sided p-value
Show solution and calculation
N=4 and K=n=2 give denominator C(4,2)=6.
Observed table mass is 1/6. x=0 is equally rare, while x=1 has the larger mass 4/6.
Hence p2=(1+1)/6=1/3.
Rearrange · Foundation
N=20,K=9,n=7 and a=3 are known. Find b,c,d of [[a,b],[c,d]].
Show hint
The first row sums to n and first column to K.
Learning goal: Reconstruct a table from margins
Show solution and calculation
b=n−a=4, c=K−a=6 and d=N−K−n+a=7.
All cells are nonnegative; rows sum to 7 and 13 and columns to 9 and 11.
Interpret · Application
In example one, p≤=7/39 and p2=38/143. Why cannot p2 be replaced by 2p≤?
Show hint
The hypergeometric null distribution is discrete and asymmetric here.
Learning goal: Distinguish two-sided conventions
Show solution and calculation
Probability ordering sums precisely the tables whose mass is no greater than observed: x=0,1,4,5.
Equal tail contributions are not required; 2·7/39=14/39≈0.358974 would be a different rule, not the same test value.
Error analysis · Application
For [[1,4],[5,3]], table mass 70/429 is reported as a two-sided p-value. Correct this.
Show hint
Other equally or less probable tables also count.
Learning goal: Separate table mass from test p-value
Show solution and calculation
70/429 is only P(observed table).
Sum weights 21,210,105,6: p2=342/1287=38/143≈0.265734.
Using observed mass alone makes the result too small here.
Transfer · Challenge
Swap the rows of [[5,1],[1,5]]. How do the two-sided and upper-tail values change?
Show hint
The new observed upper-left count is 1 rather than 5.
Learning goal: Check row swaps and directional hypotheses
Show solution and calculation
For [[1,5],[5,1]], p2 remains 37/462.
The new upper-tail value is P(X≥1)=923/924, equal to the old lower-tail value.
The old upper-tail 37/924 becomes the new lower-tail value.
Check your understanding with the formula’s reference test.
8 test questions · English materials
Already have an account? Sign in for the testAvailable from Essential. A ready-made formula set, no AI credits required. Article exercises are not all included.
Sources for this explanation
Quanta · Updated November 9, 2026
- R stats: Fisher's Exact Test for Count Data — Details and Value
- SciPy: fisher_exact — Null hypothesis and p-values; Odds ratio
Editorial responsibility: Quanta Study editorial team
Review scope
This explanation, 2 worked examples and 5 exercises are available in German and English. Structure, source references and mathematical notation undergo automated checks. Calculations, model assumptions and both language versions receive a separate AI review.
An independent, named human subject review has not yet been documented. Our exercise numbers are worked examples, rather than measurements published by the cited sources.
Editorial responsibility, sources and methodsChange history
- Added a full DE/EN article with explicit probability ordering, a discrete graphic, two original examples and five checked exercise paths.
Cite this reference page
Quanta. Fisher's Exact Test. Updated November 9, 2026. https://quanta-study.de/en/formula-sheet/fisher-exakt-test
When citing a specific scientific statement, also cite the specialist source linked to that statement.