The basic equation underlying exact tests is
where:
and where the sum ranges over all outcomes y (including the observed one) that have the same value of the test statistic obtained for the observed sample x, or a larger one.
Main article: Pearson's chi-squared test
A simple example of this concept involves the observation that Pearson's chi-squared test is an approximate test. Suppose Pearson's chi-squared test is used to ascertain whether a six-sided die is "fair", indicating that it renders each of the six possible outcomes equally often. If the die is thrown n times, then one "expects" to see each outcome n/6 times. The test statistic is
where Xk is the number of times outcome k is observed. If the null hypothesis of "fairness" is true, then the probability distribution of the test statistic can be made as close as desired to the chi-squared distribution with 5 degrees of freedom by making the sample size n sufficiently large. On the other hand, if n is small, then the probabilities based on chi-squared distributions may not be sufficiently close approximations. Finding the exact probability that this test statistic exceeds a certain value would then require a combinatorial enumeration of all outcomes of the experiment that gives rise to such a large value of the test statistic. It is then questionable whether the same test statistic ought to be used. A likelihood-ratio test might be preferred, and the test statistic might not be a monotone function of the one above.
Main article: Fisher's exact test
Fisher's exact test, based on the work of Ronald Fisher and E. J. G. Pitman in the 1930s, is exact because the sampling distribution (conditional on the marginals) is known exactly. This should be compared with Pearson's chi-squared test, which (although it tests the same null) is not exact because the distribution of the test statistic is only asymptotically correct.