When the distribution refuses to cooperate
The t-test and the F test are built on a normal-error story, and that story is often false in a way that matters. Waiting times, income, revenue per customer, and the counts behind most operational metrics are right-skewed with heavy tails, and a handful of extreme values can move a mean far enough to flip a conclusion. Nonparametric methods exist for this situation: they replace assumptions about the shape of the distribution with assumptions about ordering, which data almost always supports even when the normal model does not.
The trade is explicit. Rank-based tests throw away the magnitude information in the data, keeping only which observation came first, second, and so on. That costs a little power when the normal assumption happens to be true â typically a few percent â and buys robustness when it does not, because no single extreme value can exceed the largest rank. For heavily contaminated data the exchange is overwhelmingly favourable, and for clean normal data the loss is small enough that the safer default rarely costs you a real finding.
The parametric to nonparametric mapping
Almost every classical test has a rank-based counterpart with the same design and a different error distribution. The mapping is close to one-to-one, which makes switching simple: identify the parametric test your design would call for, then take the row below it in the table. The hypotheses shift slightly â rank tests generally address distributions or medians rather than means â and that difference in the research question is the part worth stating carefully in a report.
| Design | Parametric test | Nonparametric counterpart | What it assesses |
|---|---|---|---|
| Two independent groups | Two-sample t | Mann-Whitney U | Whether the distributions differ |
| Paired or matched | Paired t | Wilcoxon signed-rank | Whether the median difference is zero |
| Three or more independent groups | One-way ANOVA | Kruskal-Wallis | Whether any group distribution differs |
| Repeated measures, several conditions | Repeated-measures ANOVA | Friedman | Whether treatment effects differ |
| Any statistic, any design | Corresponding parametric test | Permutation test | Whether the observed statistic is unusual under the null |
The Friedman test deserves a note because it handles the structure that analysis of variance handles badly: the same subjects measured under several conditions. By ranking within each subject it removes subject-to-subject variation the way a paired test does, then tests across conditions, which is exactly the arrangement of a crossover trial or a benchmark run of several algorithms on the same datasets.
Rank tests and what they really compare
Mann-Whitney pools both groups, ranks every observation, and asks whether one group's ranks are systematically higher. The U statistic counts the number of times an observation from one group precedes one from the other, so it is directly interpretable as a pairwise win rate. Under the null the expected value is half of all cross-group pairs, and the reference distribution is known exactly for small samples and approximately normal for larger ones.
The subtle point is what rejection means. Mann-Whitney tests equality of distributions, and only under an additional assumption of similarly shaped distributions does that reduce to a difference in medians. If one group is merely more spread out with the same centre, the test can reject even though the medians match â which is a real finding, just not the one a headline about medians would claim. Wilcoxon signed-rank is the paired analogue, applied to differences, and it assumes those differences are symmetric about their centre; when symmetry is doubtful, the sign test drops that assumption entirely and pays for it in power.
Permutation tests: exact by construction
A permutation test sidesteps distributional theory completely. Compute the statistic you care about on the observed data, then shuffle the group labels repeatedly, recomputing the statistic each time, and measure how often the shuffled values reach or exceed the observed one. The resulting p-value is exact for that dataset under the sharp null that labels are interchangeable, because it is built from the actual reference distribution rather than an approximation to it.
The elegance is that the test statistic is a free choice. You can permute a difference in means, a difference in medians, a ratio, a trimmed mean, or a custom metric with no derivation whatsoever, and the validity does not change. The cost is computation: exact enumeration grows factorially, so practical implementations sample from the permutation space, and the Monte Carlo p-value has its own uncertainty of roughly the square root of p over the number of shuffles. Permutation is also the natural approach for very small samples, where asymptotic approximations have not yet kicked in.
Choosing between robust and efficient
Efficiency is the sample size a nonparametric test needs to match the power of the parametric one under ideal conditions. For the normal case, Mann-Whitney reaches about ninety-five percent efficiency relative to the t-test, so detecting the same effect needs roughly five percent more observations. Under heavier tails the ordering reverses and the rank test can be substantially more powerful, because the t-test is wasting effort on a model that does not fit.
The practical decision tree is short. Check the shape and the outliers first; if they are mild and the sample is large, the central limit theorem carries the parametric test and efficiency argues for using it. If the data are strongly skewed, ordinal, or visibly contaminated, reach for the rank test. If the sample is small and the statistic is unusual, permute. Report the effect size appropriate to the method â rank-biserial correlation or Cliff's delta for two groups, epsilon-squared for several â because a p-value from a rank test is no more interpretable than one from a t-test without a magnitude attached.
Running rank and permutation tests in Python
import numpy as np
from scipy import stats
rng = np.random.default_rng(23)
control = rng.exponential(scale=8.0, size=30)
treated = rng.exponential(scale=14.0, size=32)
print("t-test :", stats.ttest_ind(control, treated))
print("Mann-Whitney U:", stats.mannwhitneyu(control, treated,
alternative="two-sided"))
print("medians :", np.median(control), np.median(treated))
print("means :", control.mean(), treated.mean())
u_stat, p_mw = stats.mannwhitneyu(control, treated)
rank_biserial = 2 * u_stat / (len(control) * len(treated)) - 1
print(f"rank-biserial r = {rank_biserial:.3f}")
before = rng.normal(100, 18, 25)
after = before + rng.normal(-7, 6, 25)
print("paired t :", stats.ttest_rel(after, before))
print("Wilcoxon :", stats.wilcoxon(after, before))
With exponential data the means are dragged well above the medians, and the t-test's p-value reflects a comparison of quantities the data cannot support cleanly. The rank test answers the question the data can actually answer, and the rank-biserial correlation at the end translates the result into an effect size that reads as a probability of superiority.
The second block implements a permutation test from scratch so the mechanics are visible.
import numpy as np
from scipy import stats
def permutation_test(a, b, statistic=np.mean, n_perm=20_000, seed=0):
"""Two-sided permutation test by label shuffling."""
rng = np.random.default_rng(seed)
pooled = np.concatenate([a, b])
n_a = len(a)
observed = statistic(a) - statistic(b)
combined = np.empty(n_perm)
for i in range(n_perm):
rng.shuffle(pooled)
combined[i] = statistic(pooled[:n_a]) - statistic(pooled[n_a:])
p = (np.abs(combined) >= abs(observed)).mean()
return observed, p, combined
group_a = np.array([4.2, 5.1, 3.8, 6.0, 4.9, 5.5, 4.4, 5.8])
group_b = np.array([6.1, 7.3, 5.9, 6.8, 7.0, 6.4, 7.5, 6.2])
obs, p_perm, null = permutation_test(group_a, group_b)
print(f"observed difference = {obs:.3f}, permutation p = {p_perm:.4f}")
print("parametric p (t):", stats.ttest_ind(group_a, group_b).pvalue)
print("null 2.5% / 97.5%:",
np.round(np.percentile(null, [2.5, 97.5]), 3))
The permutation p-value agrees with the parametric one here, which is reassuring rather than surprising: with clean, roughly symmetric data the two approaches converge. The percentile range of the null distribution shows directly how unusual the observed difference is relative to what pure label shuffling produces.
Nonparametric misreadings
Common Mistakes
Claiming Mann-Whitney tests a difference in medians unconditionally
Fix: It tests distributional equality; a median claim needs the shapes to be comparable as well.
Switching to a rank test only after the parametric one fails
Fix: Choose the method from the data type and design before running anything, and report the pre-specified choice.
Expecting rank tests to survive dependence
Fix: Ranks fix distributional problems, not violated independence; clustered data still needs a clustered analysis.
Reporting only the p-value from a permutation test
Fix: State the statistic that was permuted, the number of shuffles, and an effect size.
Over-differencing or over-transforming before ranking
Fix: Rank tests are already robust; extra transformations cost information without adding validity.
Comparing a rank test's p-value against a parametric effect size
Fix: Use rank-biserial correlation, Cliff's delta, or epsilon-squared to match the method.
Nonparametric essentials
Where to go next
- Permutation Tests develops exact inference and Monte Carlo implementations.
- Wilcoxon Signed-Rank Test covers paired designs with full derivations.
- Mann-Whitney U Test explains rank-biserial effect sizes and ties.
- Kruskal-Wallis Test extends the rank approach to several independent groups.