Mann-Whitney U test
The Mann-Whitney U test, also called the Wilcoxon rank-sum test, is the non-parametric alternative to the independent samples t-test. It compares two separate groups without assuming the data are normally distributed, which makes it the standard choice for rating-scale outcomes, skewed measurements and small samples.
How it works
Pool all the values from both groups and rank them from smallest (rank 1) to largest. Tied values share the average of their ranks. If the groups don’t differ, high and low ranks should be spread evenly between them. If one group’s values tend to be larger, it collects most of the high ranks.
The U statistic has a very intuitive meaning: take every possible pair of one value from group 1 and one from group 2, and count how many pairs the group 1 value wins (ties count as half). With 10 and 12 observations there are 10 × 12 = 120 pairs. If the groups were the same, you’d expect group 1 to win about half, so U near 60.
Hypotheses
- H₀: the two populations have the same distribution. Equivalently, a random value from one group is equally likely to be larger or smaller than a random value from the other.
- H₁: values in one population tend to be larger than in the other.
It’s often described as a test of medians. That’s only strictly true if the two distributions have the same shape and differ only in location. In general, read it as a test of whether one group tends to have higher values.
When to use it
- The outcome is ordinal, such as a single Likert item, a ranking or a rating.
- The outcome is continuous but clearly skewed, or has genuine outliers.
- The groups are small and you can’t rely on normality.
With moderate, well-behaved samples, the t-test and Mann-Whitney usually agree. See parametric vs non-parametric tests for the trade-offs.
Assumptions
- Independent observations, and two separate groups. For paired data, use the Wilcoxon signed-rank test.
- An outcome that can be ranked (ordinal or continuous).
- No normality or equal-variance assumption. But if the groups have very different spreads, a significant result may reflect a difference in shape rather than a shift in typical values.
Worked example: chick weights on two feeds
In a 1940s feeding experiment, newly hatched chicks were randomly allocated to different feed supplements and weighed after six weeks. The data ship with R as chickwts. We compare two of the feeds: horsebean (10 chicks) and linseed (12 chicks).
Step 1: describe
| Feed | n | Median (g) | IQR |
|---|---|---|---|
| Horsebean | 10 | 151.5 | 39.25 |
| Linseed | 12 | 221.0 | 79.75 |
Step 2: choose the test
With only 10 and 12 chicks per group, normality can’t be checked reliably, and the t-test’s robustness to non-normality can’t be relied on. Analytika requires at least 20 per group before it uses a t-test, so on this file it chooses the Mann-Whitney U test.
Step 3: run the test
Group 1 (horsebean): median=151.5000, n=10, iqr=39.2500 Group 2 (linseed): median=221.0000, n=12, iqr=79.7500 U-statistic: 20.0000 P-value: 0.007145 Effect size r: -0.6667 95% CI: [-0.8891, -0.1895] Rows excluded for missing values: 0 of 22
> wilcox.test(weight ~ feed, data = cw) Wilcoxon rank sum exact test data: weight by feed W = 20, p-value = 0.007145 alternative hypothesis: true location shift is not equal to 0
R calls the statistic W, but it’s the same U for the first group (horsebean). The p-values match, and both use the exact distribution, which is appropriate here with small groups and no ties. Analytika’s test suite checks this case against R on every change.
Step 4: interpret
- U = 20 out of a possible 120: a horsebean chick was heavier than a linseed chick in only 20 of the 120 possible pairings (17%).
- p = .007: there’s evidence that chick weights differ between the two feeds, with linseed chicks tending to be heavier.
- Rank-biserial r = −.67, 95% CI [−.89, −.19]. This is the difference between the share of pairings horsebean wins (17%) and the share it loses (83%). It’s a large effect, though with only 22 chicks the interval is wide.
A Welch’s t-test on the same data gives p = .007, so the conclusion doesn’t hinge on the choice of test. That’s reassuring, but the test still has to be chosen beforehand, not after comparing p-values.
Step 5: report it (APA 7)
A Mann-Whitney U test found that chicks fed linseed (Mdn = 221.0 g) tended to weigh more than chicks fed horsebean (Mdn = 151.5 g), U = 20, p = .007, r = −.67, 95% CI [−.89, −.19].
Because the chicks were randomly allocated to feeds, this experiment supports a causal reading (the feed affected weight). In an observational comparison you’d describe it as a difference between groups only.
Common mistakes
- Reporting means and SDs with a rank-based test. Report medians and IQRs.
- Using it for paired data. Before/after scores need the Wilcoxon signed-rank test.
- Calling it “a test of medians” without qualification when the groups have very different shapes.
- Reporting U without an effect size. The rank-biserial r makes the result interpretable.
How to run it
- SPSS: Analyze → Nonparametric Tests → Independent Samples (or Legacy Dialogs → 2 Independent Samples).
- R:
wilcox.test(outcome ~ group, data = df) - Python:
scipy.stats.mannwhitneyu(a, b) - Analytika: ask whether the outcome differs between the two groups. If the checks rule out the t-test, it runs Mann-Whitney and says why.
More in Comparing groups
Try it with the free tools
Run this on your own data
Upload a dataset and ask your question in plain English. Analytika checks the assumptions, picks the test, runs it, and writes the results up in APA format.