Understanding the Mann-Whitney U test — concept and principle
The Mann-Whitney U test (also called the Wilcoxon rank-sum test) compares two independent groups without assuming normal data. It works on ranks instead of raw values, so it suits small samples, skewed measurements, outliers and ordinal scales such as satisfaction ratings. Enter the values of group A and group B; the calculator returns U, a z score and an approximate two-tailed p-value.
How it is calculated
- Pool both groups and rank all values from smallest (rank 1) to largest. Tied values receive the average of the ranks they occupy.
- Add the ranks of group A to get R₁.
- U₁ = R₁ − n₁(n₁ + 1) ÷ 2, and U₂ = n₁n₂ − U₁. The reported U is the smaller of the two.
- Normal approximation: z = (U₁ − n₁n₂ ÷ 2) ÷ √(n₁n₂(n₁ + n₂ + 1) ÷ 12).
- Two-tailed p = 2 × (1 − Φ(|z|)).
A positive z means group A tends to have higher values.
The principle
U₁ counts, over all n₁ × n₂ pairs of one value from A and one from B, how many times the A value is larger (ties count one half). If both groups come from the same distribution, A wins each pair half the time, so U₁ is centred at n₁n₂ ÷ 2. Its variance under that null hypothesis is n₁n₂(n₁ + n₂ + 1) ÷ 12, and for moderate samples U is close to normally distributed. The test was developed by Wilcoxon (1945) and by Mann and Whitney (1947).
Worked example
- A = 3, 5, 6, 8, 9; B = 1, 2, 4, 4, 7; n₁ = n₂ = 5.
- Pooled ranks: 1→1, 2→2, 3→3, 4 and 4→4.5 each, 5→6, 6→7, 7→8, 8→9, 9→10.
- R₁ = 3 + 6 + 7 + 9 + 10 = 35.
- U₁ = 35 − 15 = 20, U₂ = 25 − 20 = 5, so U = 5.
- z = (20 − 12.5) ÷ √(25 × 11 ÷ 12) = 7.5 ÷ 4.787 ≈ 1.5667.
- p ≈ 0.1172 (two-tailed, normal approximation).
How to read the result
U ranges from 0 (complete separation of the groups) to n₁n₂ ÷ 2 (complete overlap). Here A ranks higher on average, but p ≈ 0.12 is above 0.05, so the difference is not significant. For n₁ = n₂ = 5, exact tables require U ≤ 2 for significance at the two-tailed 5% level; the exact p for U = 5 is about 0.15. A useful effect size is U₁ ÷ (n₁n₂) = 0.8: an A value beats a B value in 80% of pairs.
Common mistakes
- Using it for paired data; paired samples need the Wilcoxon signed-rank test.
- Describing it as a test of medians without qualification; it compares whole distributions.
- Forgetting that the reported U is the smaller value, so it alone does not show which group is higher.
Frequently asked questions
When should I prefer it over the t-test?
When data are ordinal, clearly skewed or contain outliers, and the sample is too small to rely on the central limit theorem.
Is it the same as the Wilcoxon rank-sum test?
Yes. The statistics differ only by a constant, W = U + n(n + 1) ÷ 2, and give the same p-value.
Do the groups need equal sizes?
No. Any n₁ and n₂ of at least 2 work here.
Sources: Mann, H. B. & Whitney, D. R. (1947). Annals of Mathematical Statistics, 18(1), 50–60. · Wilcoxon, F. (1945). Biometrics Bulletin, 1(6), 80–83.