Mathwords logoMathwords

Permutation Test — Definition, Formula & Example

A permutation test is a way to test whether two groups really differ. You shuffle the group labels many times and check how often chance alone gives a difference as large as the one you observed.

A permutation test is a nonparametric hypothesis test. Under the null hypothesis, the observations are exchangeable across groups. The null distribution of a test statistic TT is the set of values of TT computed over all (or a random sample of) reassignments of the observed data to the groups, keeping the group sizes fixed. The p-value is the proportion of those reassignments whose statistic is at least as extreme as the observed TobsT_{\text{obs}}.

Key Formula

p=#{ rearrangements with T∗≥Tobs }total number of rearrangementsp = \frac{\#\{\,\text{rearrangements with } T^* \ge T_{\text{obs}}\,\}}{\text{total number of rearrangements}}
Where:
  • TobsT_{\text{obs}} = Test statistic from the real data, such as a difference in group means
  • T∗T^* = The same statistic recomputed after the labels are rearranged
  • pp = One-sided p-value; for a two-sided test, compare absolute values instead

Worked Example

Problem: A gardener gives fertilizer to 3 tomato plants and leaves 3 plants unfertilized. After one month, the fertilized plants grew 6, 9, and 12 inches. The unfertilized plants grew 3, 5, and 7 inches. Use an exact permutation test to decide whether fertilizer increases growth, at the 0.05 significance level.
Step 1: Compute the observed statistic, the difference in mean growth (fertilized minus unfertilized). Under H0H_0, fertilizer has no effect, so any 3 of the 6 values could have carried the label "fertilized."
Tobs=6+9+123−3+5+73=9−5=4 inchesT_{\text{obs}} = \frac{6+9+12}{3} - \frac{3+5+7}{3} = 9 - 5 = 4 \text{ inches}
Step 2: Count all ways to choose which 3 values are labeled "fertilized." The 6 values sum to 42, so a larger fertilized total always means a larger difference. A difference of at least 4 requires a fertilized total of at least 27. Only two splits qualify: {6,9,12}\{6, 9, 12\} (the real one, total 27) and {7,9,12}\{7, 9, 12\} (total 28), whose difference is shown below.
(63)=20,283−143=143≈4.67≥4\binom{6}{3} = 20, \qquad \frac{28}{3} - \frac{14}{3} = \frac{14}{3} \approx 4.67 \ge 4
Step 3: Divide the number of splits at least as extreme as the observed one by the total number of splits.
p=220=0.10>0.05p = \frac{2}{20} = 0.10 > 0.05
Answer: The exact p-value is 0.10. This is greater than 0.05, so you fail to reject H0H_0. Six plants are not enough evidence that the fertilizer increases growth.

Why It Matters

Permutation tests need no assumption of a normal distribution, so they work for small samples and skewed data where a t-test is unreliable. Tech companies use them to analyze A/B tests, and biologists use them to compare gene expression between groups. Many introductory college statistics courses now teach inference through these randomization simulations before formula-based tests.

Common Mistakes

Mistake: Leaving the observed arrangement out of the count, which would give p=1/20p = 1/20 in the example above.
Correction: The real labeling is one of the possible rearrangements, and it is always at least as extreme as itself. Count it. When you sample random shuffles instead of listing them all, use (1+count)/(1+B)(1 + \text{count})/(1 + B) for BB shuffles.

Related Terms