Omni Calculator logo

Fisher's Exact Test Calculator

Created by Anna Szczepanek, PhD
Reviewed by Dominik Czernia, PhD and Jack Bowater
Last updated: Jun 05, 2023


This Fisher's exact test calculator computes both the one-tailed and two-tailed p-value for a Fisher's exact test on any 2 x 2 contingency table. To compute the p-value of other statistical tests, visit our p-value 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 left-handedness 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 p-value 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 chi-squared test, which is another popular test for independence.

When to use Fisher's exact test vs. chi-squared test?

Fisher's exact test and the chi-squared test are two most popular statistical tests for independence:

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

  • The chi-squared test is only an approximate test because the sampling distribution of the test statistic is only approximately (asymptotically) equal to the chi-square distribution.

When to use Fisher's exact test?

Choose the Fisher exact test rather than the chi-squared 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 chi-squared test is based might not be very accurate in such conditions.

When to use chi-square 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 well-balanced. Fortunately, there are the conditions under which the approximation used in the chi-squared 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:

(a+ba)(c+dc)(na+c)\frac{{{a+b} \choose {a}} {{c+d} \choose c}}{{n} \choose {a+c}}

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:

(a+b)!a!b!(c+d)!c!d!n!(a+c)!(b+d)!\frac{\frac{(a+b)!}{a!b!} \cdot \frac{(c+d)!}{c!d!}}{\frac{n!}{(a+c)!(b+d)!}}

and then as

(a+b)!(c+d)!(a+c)!(b+d)!a!b!c!d!n!\small \frac{(a+b)!(c+d)!(a+c)!(b+d)!}{a!b!c!d!n!}

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 p-value for a Fisher's exact test, we have to find all possible matrices of non-negative 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 two-tailed p-value:

two-tailed p-value

For a two-tailed test, you add together the probabilities of every table that has a probability lower than or the same as that of the observed table.

one-tailed p-value

For a one-tailed 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 to a in the upper-left corner, including the observed table.

  • If a > b, then sum the probabilities of all tables that have a value greater than or equal to a in the upper-left 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 two-tailed Fisher's exact test, go for the latter option. You need a really good reason to use a one-tailed 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 p-value of this Fisher's exact test!

One-tailed p-value 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

Two-tailed p-value 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:

  1. First of all, enter the 2 x 2 contingency table that you observed, i.e. enter a, b, c, and d.
  2. Decide whether you need the one- or two-tailed p-value. If unsure, check the section Definition of Fisher's exact test.
  3. When all necessary input is present, our Fisher's exact test calculator displays the result of your test.
Anna Szczepanek, PhD
Contingency
a
b
c
d
Test type
Two-tailed
p-value
Odds ratio
Check out 26 similar inference, regression, and statistical tests calculators 📉
Absolute uncertaintyAB testCoefficient of determination… 23 more
People also viewed…

Addiction

Addiction calculator tells you how much shorter your life would be if you were addicted to alcohol, cigarettes, cocaine, methamphetamine, methadone, or heroin.

BMR - Harris-Benedict equation

Harris-Benedict calculator uses one of the three most popular BMR formulas. Knowing your BMR (basal metabolic weight) may help you make important decisions about your diet and lifestyle.

Point estimate

Point estimate calculator computes the "best guess" of an unknown population parameter.

Third quartile

This third quartile calculator can help you discover all the interesting properties of the upper quartile.
Copyright by Omni Calculator sp. z o.o.
Privacy, Cookies & Terms of Service