Fisher's Exact Test Calculator
This Fisher's exact test calculator computes both the onetailed and twotailed pvalue for a Fisher's exact test on any 2 x 2 contingency table. To compute the pvalue of other statistical tests, visit our pvalue calculator.
Not sure what Fisher's exact test is? Are you wondering when to use Fisher's exact test or are you looking for a Fisher's exact test example? Scroll down  we give you the Fisher's exact test definition and explain how to calculate Fisher's exact test by hand!
What is Fisher's exact test?
In statistics, Fisher's exact test is a statistical test of independence for categorical variables. We most commonly apply it when there are two variables, and each variable has two possible values (we call such variables "dichotomous"), so we can represent data in a 2 x 2 contingency table (e.g., sex vs. handedness).
We use Fisher's exact test to determine if there is a dependence (contingency) between the two variables, i.e., whether the proportions of one variable differ depending on the value of the other variable (e.g., if lefthandedness is more prevalent among men than among women). If there is no dependency, then the two variables are called independent.
Unlike other statistical tests, there is no formula for test statistics. To perform Fisher's exact test, we calculate the pvalue directly, according to the hypergeometric distribution. We give more details in the third section of this Fisher's exact test calculator. First, however, let's discuss when you should use Fisher's exact test instead of the chisquared test, which is another popular test for independence.
When to use Fisher's exact test vs. chisquared test?
Fisher's exact test and the chisquared test are two most popular statistical tests for independence:

Fisher's test is an exact test because we know the exact sampling distribution.

The chisquared test is only an approximate test because the sampling distribution of the test statistic is only approximately (asymptotically) equal to the chisquare distribution.
When to use Fisher's exact test?
Choose the Fisher exact test rather than the chisquared test if the sample size is small, the marginals are very uneven, or there is a small value (less than five) in one of the cells. This is because the approximation on which the chisquared test is based might not be very accurate in such conditions.
When to use chisquare test?
Since we have to compute factorials, Fisher's exact test is hard to calculate when the sample is large or the contingency table is wellbalanced. Fortunately, there are the conditions under which the approximation used in the chisquared test flourishes! ๐ผ
Definition of Fisher's exact test
As you now have a general idea of what Fisher's exact test is, it is high time we tell you how to perform it.
The null hypothesis is that the two variables are independent; in other words, that the proportions of one variable are the same for all of the different values of the other variable.
Consider a 2 x 2 contingency table with the cell frequencies represented by a
, b
, c
, and d
:
category 1  category 2  

group 1  a  b 
group 2  c  d 
We need to find the marginal totals and the grand total n
:
category 1  category 2  

group 1  a  b  a+b 
group 2  c  d  c+d 
a+c  b+d  a+b+c+d 
Fisher showed that, under the assumption that the null hypothesis holds and the values for the marginal totals are fixed, the probability of observing the above table is given by the hypergeometric distribution, which looks like this:
where we see three different binomial coefficients. If you want to discover more about these concepts, check out the hypergeometric distribution calculator and the binomial coefficient calculator, or trust us that the formula above can be rewritten as follows:
and then as
where !
denotes the factorial. If you don't know what it means and how to compute it, visit Omni's factorial calculator.
๐ Tip. Observe that if we know the marginal totals, only a single degree of freedom is left. The value, e.g., of a
, is sufficient to deduce all the other values. Thus, the probability discussed above depends only on a
!
To find the pvalue for a Fisher's exact test, we have to find all possible matrices of nonnegative integers with the same row and column totals as the original table and then calculate the probability of each such table. The next step depends on whether you want to determine the one or twotailed pvalue:
twotailed pvalue
For a twotailed test, you add together the probabilities of every table that has a probability lower than or the same as that of the observed table.
onetailed pvalue
For a onetailed test, we want to take into account only those tables that are more extreme than the observed table, but only in one direction:

If
a < b
, then sum the probabilities of all tables that have a value lower than or equal toa
in the upperleft corner, including the observed table. 
If
a > b
, then sum the probabilities of all tables that have a value greater than or equal toa
in the upperleft corner, including the observed table. 
If
a = b
, you can pick either of the above options: the results will be the same.
Tip. If you're unsure whether to use a one or twotailed Fisher's exact test, go for the latter option. You need a really good reason to use a onetailed test  do it if you are interested in testing only the positive or the negative correlation between the variables.
Check our Fisher's exact test example below to see how to calculate Fisher's exact test on some real data!
How to calculate Fisher's exact test?  an example
We ask 11 people: 5 men and 6 women whether they prefer cycling or swimming. Only one man chose swimming and only two women chose cycling. The remaining people chose the other option. Let's collect our data in a contingency table:
S  C  

M  1  4  
W  4  2 
where C for cycling, S stands for swimming, M for men, and W for women.
We calculate the marginal totals:
S  C  

M  1  4  5  
W  4  2  6  
5  6  11 
The probability of observing this table is equal to:
5! 6! 5! 6! / (1! 4! 4! 2! 11!) โ 0.16234
Let's display all possible tables (with the same total margins as the original table) and calculate their probabilities:
S  C  

M  0  5  
W  5  1  
Probability of this table:
5! 6! 5! 6! / (0! 5! 5! 1! 11!) โ 0.01299
S  C  

M  2  3  
W  3  3 
Probability of this table:
5! 6! 5! 6! / (2! 3! 3! 3! 11!) โ 0.43290
S  C  

M  3  2  
W  2  4 
Probability of this table:
5! 6! 5! 6! / (3! 2! 2! 4! 11!) โ 0.32468
S  C  

M  4  1  
W  1  5 
Probability of this table:
5! 6! 5! 6! / (4! 1! 1! 5! 11!) โ 0.06494
S  C  

M  5  0  
W  0  6 
Probability of this table:
5! 6! 5! 6! / (5! 0! 0! 6! 11!) โ 0.00216
Now we have enough information to calculate the pvalue of this Fisher's exact test!
Onetailed pvalue is (approximately) equal to
0.01299 + 0.16234 = 0.17532
.
This number is the sum of the probability of the observed table and of the table:
S  C  

M  0  5  
W  5  1  
Twotailed pvalue is (approximately) equal to
0.01299 + 0.16234 + 06494 + 0.00216 = 0.24242
i.e., to the sum of probabilities of the observed table and of the following tables:
S  C  

M  0  5  
W  5  1  
S  C  

M  4  1  
W  1  5  
S  C  

M  5  0  
W  0  6  
We hope that everything is now clear after this Fisher's exact test example ๐
How to use this Fisher's exact test calculator?
To use the Fisher's exact test calculator you need to do the following:
 First of all, enter the 2 x 2 contingency table that you observed, i.e. enter a, b, c, and d.
 Decide whether you need the one or twotailed pvalue. If unsure, check the section Definition of Fisher's exact test.
 When all necessary input is present, our Fisher's exact test calculator displays the result of your test.