Non-Parametric Tests
Learn distribution-free statistical tests for when parametric assumptions fail. Master Mann-Whitney, Wilcoxon, and Kruskal-Wallis tests.
On This Page
Fewer distributional assumptions does not mean no assumptions
Rank-based and other non-parametric methods can be useful for ordinal outcomes, influential extreme values, or questions about distributions rather than means. They still depend on study design, independence or pairing, and often additional assumptions for a particular interpretation.
A small sample is not by itself a reason to abandon a t-test, and a large sample is not by itself a reason to trust one. First identify the estimand: the quantity or feature you want to learn about.
Choose by design and question
| Design | Common method | Important qualification |
|---|---|---|
| Two independent groups | Mann–Whitney U / Wilcoxon rank-sum | Distributional comparison; not generally a test of means or medians |
| Matched pairs | Wilcoxon signed-rank | A location interpretation requires symmetric differences |
| Matched pairs, directional changes only | Sign test | Discards magnitudes and handles a different question |
| Three or more independent groups | Kruskal–Wallis | Overall rank/distribution comparison, not which pairs differ |
| Two variables, monotonic association | Spearman correlation | Captures monotonic patterns, not causation |
If the question is a mean difference, a rank test may change the question. Suitable transformations, robust mean methods, or a model reflecting the data-generating process can sometimes be better choices.
Mann–Whitney: compare ranks across independent groups
Consider A = 2, 4, 6 and B = 5, 7, 9. Pool the observations and rank them from smallest to largest:
| Value | Group | Rank |
|---|---|---|
| 2 | A | 1 |
| 4 | A | 2 |
| 5 | B | 3 |
| 6 | A | 4 |
| 7 | B | 5 |
| 9 | B | 6 |
A’s rank sum is R_A = 1 + 2 + 4 = 7. Define:
The complementary U_B is n_A n_B − U_A = 8. Packages can report either group’s statistic, so identify the convention before comparing outputs.
With no ties, the two-sided exact p-value is 0.20 under the usual equal-distributions null. Tiny samples have coarse exact p-values; a visible separation need not produce a small p-value.
The test can respond to location, shape, or spread differences. Interpreting it as a median comparison requires additional common-shape/location-shift assumptions. Two groups with the same median can still differ in distribution.
Wilcoxon signed-rank: keep the pairing
Calculate each paired difference first. Ignore zero differences under the usual “wilcox” convention, rank the absolute nonzero differences, then sum positive and negative ranks.
For differences 1, −2, 3, 4, −5, the absolute values are already ranked 1 through 5:
- Positive rank sum W⁺ = 1 + 3 + 4 = 8.
- Negative rank sum W⁻ = 2 + 5 = 7.
- A common two-sided reported statistic is min(W⁺, W⁻) = 7.
Under independent, symmetrically distributed differences with no ties or zeros, the two-sided exact p-value is 1.00. The almost-balanced signed ranks give little evidence against the symmetric zero-location model.
The signed-rank method uses magnitudes through ranks, but is not assumption-free. If the distribution of differences is strongly asymmetric and the question concerns a median direction, a sign test may be more defensible. Different zero-handling conventions and ties can change the calculation.
Kruskal–Wallis: an overall independent-group test
Pool and rank all groups. With no ties, the statistic is:
R_j is group j’s rank sum. Ties require a correction. With adequate group sizes, H is compared with an approximate chi-square distribution with k − 1 df; sparse data may need an exact or permutation approach.
A significant overall result says distributions are not all the same under the model. It does not identify pairs or establish that all medians differ. Follow-up comparisons need an appropriate procedure and multiplicity control.
Spearman: measure a monotonic relationship
Spearman’s correlation is Pearson correlation applied to the ranks. A monotonic relationship consistently increases or decreases but need not be a straight line.
The shortcut ρ_s = 1 − 6Σd²/[n(n² − 1)] assumes no ties. For tied data, use average ranks and correlate them, or use software that handles ties explicitly. Inference also needs independent pairs and an appropriate method for the sample size and tie pattern.
Do not use the site’s Pearson calculator and label its result Spearman; they answer different questions.
Ties, exact methods, and reporting
Tied values usually receive average ranks. They affect the null distribution and variance. A software label of “exact” may have restrictions, especially when ties or zeros are present. Check the method rather than assuming every small-sample output is exact.
Report group sizes, median and spread where useful, the method, statistic convention, p-value method, and the study design. Add an effect measure suited to the method and explain its interpretation in context.
Practice
Two independent groups have the same median but different spreads. Can a significant Mann–Whitney result be reported as proof that their medians differ?
Show the explanation
No. Without common-shape assumptions, the test concerns broader distributional differences. Describe the distributions and state the hypothesis actually tested. If the scientific question specifically concerns medians, choose a method designed for that estimand.
References and next steps
The official SciPy documentation describes the hypotheses and calculation choices for Mann–Whitney U, Wilcoxon signed-rank, and Kruskal–Wallis. Compare these methods with t-tests and ANOVA, using the design and question rather than a normality-test cutoff alone.
Did this explanation help?
Your response helps us identify lessons that need more work.