Learning Fisher’s Exact Test: Definition, Formula, and Practical Examples


Fisher’s Exact Test: A Precise Approach to Association

The Fisher’s Exact Test stands out as a critical tool in statistical analysis, specifically designed to rigorously determine the existence of a non-random, statistically significant association between two distinct categorical variables. What sets this method apart is its commitment to exact probability calculation. Unlike numerous approximation methods, Fisher’s test computes the precise probability of observing the given data distribution, based on the crucial assumption that the marginal totals (the sums of the rows and columns) are fixed. This inherent precision makes it indispensable across diverse scientific disciplines, including biology, clinical trials, and social sciences, particularly when researchers are constrained by smaller sample sizes where traditional statistical approximations tend to break down.

This test is most commonly employed as a robust and reliable alternative to the standard Chi-Squared Test for independence. The need for Fisher’s Exact Test arises when the underlying assumptions of the Chi-Squared Test are potentially violated, a common occurrence when analyzing data organized within a 2×2 contingency table. Specifically, if one or more of the expected cell counts (under the assumption of independence) falls below the threshold of five, the Chi-Squared statistic’s theoretical distribution may not accurately model the true probability distribution. Relying on approximations in such low-count scenarios dramatically increases the risk of committing a Type I error (a false positive). By calculating exact probabilities using combinatorial methods, Fisher’s test effectively mitigates this risk, ensuring that conclusions drawn about the relationship between the variables are statistically sound and precise.

Formulating the Hypotheses for Statistical Independence

Prior to executing any statistical test, it is essential to clearly articulate the hypotheses that guide the investigation into the relationship between the two categorical variables. These statements provide the formal framework necessary for interpreting the resulting P-value and ultimately drawing a meaningful conclusion about whether the observed characteristics are truly associated or merely random. The design of Fisher’s Exact Test is centered around contrasting two opposing statements regarding independence.

Fisher’s Exact Test formally evaluates the following pair of contrasting statements:

  • H0: (The Null Hypothesis) The two categorical variables are statistically independent. This fundamental premise suggests that the distribution of one variable remains unaffected by the status, level, or grouping of the other variable. Any observed difference is assumed to be the result of random sampling variation.
  • H1: (The Alternative Hypothesis) The two categorical variables are not independent (i.e., they exhibit a genuine association or dependence). If we reject the null hypothesis, it implies that the observed relationship is strong enough to conclude that a significant association exists between the variables in the population.

The primary objective of conducting the test is to determine if the observed data configuration is sufficiently extreme—meaning unlikely to have occurred if the null hypothesis were true—to provide adequate evidence for its rejection. This judgment is made by comparing the resulting P-value against a predetermined level of statistical significance, traditionally denoted as alpha (α), which is commonly set at 0.05.

Data Organization: The Essential 2×2 Contingency Table

The foundational requirement for conducting Fisher’s Exact Test is that the raw data counts must be meticulously organized into a 2×2 contingency table. This table acts as a summary, displaying the frequency counts of observations across the four possible intersections created by the two categories under investigation. Each internal cell (conventionally labeled a, b, c, and d) records the count of subjects or observations that fall into that unique combination of variable levels. Crucially, the marginal totals—the row totals (a+b, c+d), the column totals (a+c, b+d), and the grand total (n)—must be fixed throughout the probability calculation, a constraint central to the test’s exact nature.

For illustrative purposes, consider the standard structure where rows delineate the levels of the first categorical variable and columns delineate the levels of the second variable:

Group 1Group 2Row Total
Category 1aba+b
Category 2cdc+d
Column Totala+cb+da+b+c+d = n

The power of this test derives from its ability to calculate the probability of obtaining this specific arrangement (a, b, c, d) or any arrangement showing a stronger association, given that the row and column totals remain immutable. This constraint of fixed marginal totals is fundamental, as it restricts the universe of possible outcomes, allowing the probability calculation to depend exclusively on the internal frequencies within the four cells.

The Mathematical Foundation and Hypergeometric Distribution

The central mathematical operation of Fisher’s Exact Test involves calculating the precise probability of observing the current table configuration, assuming that the null hypothesis of independence is unequivocally true. To achieve the final P-value, the test enumerates the probabilities of all possible 2×2 tables that could be constructed while maintaining the exact marginal totals observed in the original data set. The test then sums the probability of the observed table with the probabilities of all other possible tables that are “more extreme” in the direction of the observed association.

The one-tailed probability (P) for obtaining the exact observed set of cell counts (a, b, c, d) is calculated using the following formula, which utilizes factorials to determine the number of ways the cells could be filled given the fixed margins:

p = (a+b)!(c+d)!(a+c)!(b+d)! / (a!b!c!d!n!)

This exact probability calculation is remarkably linked to the probability mass function of the Hypergeometric Distribution. The Hypergeometric Distribution is a discrete probability distribution that models the probability of drawing a specific number of “successes” in a sample drawn *without replacement* from a finite population. The application of this distribution guarantees that the probability derived is exact and not reliant on large-sample approximations, which is the key strength of Fisher’s methodology.

Specifically, the calculated one-tailed P-value corresponds directly to the cumulative distribution function (CDF) of the Hypergeometric Distribution using the parameters defined by the marginal totals of the contingency table:

  • Population Size (N) = n (The grand total of all observations)
  • Population “Successes” (K) = a+b (The fixed total count in Category 1)
  • Sample Size (n) = a + c (The fixed total count in Group 1)
  • Sample “Successes” (k) = a (The observed count in the primary cell ‘a’)

This theoretical equivalence confirms the mathematical robustness of Fisher’s approach, ensuring that the probability derived reflects the true chance of observing the data under the assumption of independence.

Interpreting P-Values: The Distinction Between One-Tailed and Two-Tailed Tests

In any statistical investigation, the p-value serves as the metric for decision-making. It quantifies the probability of observing data as extreme as, or even more extreme than, the data collected, assuming that the null hypothesis is true. A small p-value provides compelling evidence against the null hypothesis, suggesting that the observed association is unlikely due to chance alone.

The one-tailed p-value, which is directly computed by the factorial formula, measures the probability of observing the current arrangement or any arrangement showing an association in the specific direction predicted or observed (e.g., if one group was hypothesized to favor a specific category). However, in the vast majority of real-world research scenarios, the researcher is interested in detecting *any* association, regardless of its direction—meaning they are testing for a relationship that could lean either way. This necessitates the use of a two-tailed test.

The calculation of the two-tailed p-value for Fisher’s Exact Test is significantly more complex than the one-tailed measure and cannot simply be found by doubling the one-tailed result. The correct two-tailed p-value is the summation of the probabilities of all possible tables (maintaining the fixed marginals) whose individual probabilities are equal to or less than the probability of the actual observed table. Due to the highly combinatorial nature of this calculation, especially when dealing with moderate to large cell counts, it is strongly recommended that researchers utilize specialized statistical software or an online statistical calculator designed specifically for this purpose. This ensures maximum computational accuracy and avoids the severe practical difficulty of manually summing these complex probabilities.

Practical Application: Analyzing Political Preference and Gender

To illustrate the direct utility of Fisher’s Exact Test, let us examine a typical scenario from social research: investigating whether a significant association exists between a person’s gender and their declared political party preference. Suppose we conduct a simple random sample of 25 registered voters, summarizing the results in the following 2×2 contingency table:

DemocratRepublicanTotal
Male4913
Female8412
Total121325

Given the small total sample size (n=25) and the presence of low cell counts (specifically, a=4 and d=4), the assumption for using the Chi-Squared approximation is violated. Therefore, Fisher’s Exact Test is the demonstrably appropriate and most reliable statistical method for this dataset.

Step 1: Define the Formal Hypotheses.

We establish the formal hypotheses for the statistical analysis:

  • H0: Gender and political party preference are independent; there is no association between the two variables in the general population.
  • H1: Gender and political party preference are not independent; there is a statistically significant association between the variables.

Step 2: Calculate the Two-Tailed P-Value.

The complex factorial calculations required to determine the two-tailed p-value are typically handled by statistical software packages, which account for the Hypergeometric Distribution across all possible extreme tables.

Fisher's Exact test example

Upon computation, the resulting two-tailed p-value for the observed data is determined to be 0.115239.

Step 3: Draw the Conclusion.

We compare the resulting p-value (0.115239) against the conventional alpha level (α = 0.05). Since the calculated p-value is substantially greater than 0.05, we must fail to reject the null hypothesis (H0). This statistical outcome leads to the conclusion that, based on this specific sample, there is insufficient evidence to confidently assert that a statistically significant association exists between gender and political party preference. Although the raw counts suggest a pattern (e.g., males leaning Republican and females leaning Democrat), this observed pattern is not strong enough to rule out the possibility that the variables are independent in the larger voter population.

Computational Resources for Implementing Fisher’s Exact Test

For researchers and students utilizing computational environments, accurate implementation of Fisher’s Exact Test requires specialized functions to manage the complex factorial and combinatorial calculations. The following resources provide essential step-by-step guidance for executing the test within popular statistical programs and programming languages, ensuring the precision that defines Fisher’s method:

How to Perform Fisher’s Exact Test in SPSS
How to Perform Fisher’s Exact Test in Python

Cite this article

Mohammed looti (2025). Learning Fisher’s Exact Test: Definition, Formula, and Practical Examples. PSYCHOLOGICAL STATISTICS. Retrieved from https://statistics.arabpsychology.com/fishers-exact-test-definition-formula-and-example/

Mohammed looti. "Learning Fisher’s Exact Test: Definition, Formula, and Practical Examples." PSYCHOLOGICAL STATISTICS, 8 Nov. 2025, https://statistics.arabpsychology.com/fishers-exact-test-definition-formula-and-example/.

Mohammed looti. "Learning Fisher’s Exact Test: Definition, Formula, and Practical Examples." PSYCHOLOGICAL STATISTICS, 2025. https://statistics.arabpsychology.com/fishers-exact-test-definition-formula-and-example/.

Mohammed looti (2025) 'Learning Fisher’s Exact Test: Definition, Formula, and Practical Examples', PSYCHOLOGICAL STATISTICS. Available at: https://statistics.arabpsychology.com/fishers-exact-test-definition-formula-and-example/.

[1] Mohammed looti, "Learning Fisher’s Exact Test: Definition, Formula, and Practical Examples," PSYCHOLOGICAL STATISTICS, vol. X, no. Y, ص Z-Z, November, 2025.

Mohammed looti. Learning Fisher’s Exact Test: Definition, Formula, and Practical Examples. PSYCHOLOGICAL STATISTICS. 2025;vol(issue):pages.

Download Post (.PDF)
Scroll to Top