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 is the set of values of 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 .
Key Formula
Where:
- = Test statistic from the real data, such as a difference in group means
- = The same statistic recomputed after the labels are rearranged
- = 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 , fertilizer has no effect, so any 3 of the 6 values could have carried the label "fertilized."
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: (the real one, total 27) and (total 28), whose difference is shown below.
Step 3: Divide the number of splits at least as extreme as the observed one by the total number of splits.
Answer: The exact p-value is 0.10. This is greater than 0.05, so you fail to reject . 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 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 for shuffles.
