A hypothesis test for contingency tables.

Fisher's exact test is a hypothesis test for contingency tables. It returns the exact probability of finding observed counts as far or further from independence, if the rows and columns were actually independent. It is based on the hypergeometric distribution.

Fisher's exact test may be contrasted with the chi-squared test for contingency tables, which compares the observed $\chi^2$ test statistic to the (continuous) chi-squared distribution to determine the p-value, instead of computing the p-value directly. This strategy is computationally inexpensive. The sampling distribution of the $\chi^2$ test statistic will match the theoretical chi-squared distribution asymptotically (i.e., with sufficiently large samples); with smaller sample sizes the match is only approximate, however. Fisher's exact test is sometimes recommended when cells have small expected frequencies and thus the chi-squared test may not be appropriate.

There is an extension for $r \times{} c$ tables due to Freeman and Halton which is sometimes known as the Fisher-Freeman-Halton test.