Bell Statistics

What is the Mann-Whitney U test?

The Mann-Whitney U test compares two groups by ranking every observation and asking whether one group's values tend to sit higher in the ordering. Because it uses only the ranks, a single enormous value counts as one place rather than as its magnitude.

Notation
U
Also called
wilcoxon rank-sum test, mann-whitney-wilcoxon test, rank-sum test, non-parametric test
Allon Korem

Written by Allon Korem

Chief Executive Officer

Last updated

In plain English

Pool every observation from both groups, sort them, and give each one its position in that ordering. If the two groups are alike, their ranks should be thoroughly mixed; if one group tends to produce larger values, its members will cluster towards the top. The Mann-Whitney U test measures how far the actual mixing is from what chance would produce. Nothing about the magnitudes survives this step — the largest value in the dataset is simply the highest rank, whether it exceeds the runner-up by a penny or by fifty thousand pounds.

That insensitivity is the point. Revenue per user, order value, session duration and lifetime value all share a shape: most observations modest, a long right tail, and occasionally a customer who spends more than the next hundred combined. A mean is a poor summary of that distribution and a t-test on it can be dominated by two or three people. Ranking flattens the tail and produces a comparison that does not hinge on whether one whale happened to land in the treatment arm.

The cost is that it answers a different question, and the difference matters more than it first appears. A t-test asks whether the group *means* differ. Mann-Whitney asks whether a randomly chosen observation from one group tends to exceed one from the other — a claim about the typical case rather than the total. For a product decision those can diverge sharply: a pricing change that slightly reduces what most customers spend while substantially increasing what a few spend can be a clear win on revenue and a clear loss on ranks. The test is not wrong there; it is answering the question you asked rather than the one you needed.

It is also not assumption-free, despite the "non-parametric" label. To read a significant result as a shift in the middle of the distribution, the two distributions need roughly the same shape — if the treatment changes the spread rather than the location, U can be significant with identical medians. And it is not automatically less powerful than a t-test: on heavily skewed data it is frequently more powerful, because it is not spending precision on outliers. On symmetric data it retains about 95% of the t-test's power, which is a small premium for robustness.

In practice the choice is usually decided by a quick check rather than a rule: does removing the top 0.1% of observations change the conclusion? If it does, the mean is being carried by a handful of points and either rank-based testing or winsorising is called for. If it does not, use the t-test and report a difference in units the business recognises. We work through the wider question in what to do when data is not normally distributed.

The formula

The statistic counts how often one group beats the other across all possible pairings. At experiment sample sizes it is read through a normal approximation rather than an exact enumeration.

The U statistic
U₁ = R₁ − n₁(n₁ + 1) / 2

R₁ is the sum of ranks in group 1. Subtracting the minimum possible rank sum leaves how far above the floor the group landed.

What it counts
U = number of pairs (i, j) where xᵢ > yⱼ

Equivalent to the formula above and much more interpretable: out of every cross-group pairing, how often did group 1 win?

The effect size it implies
P( X > Y ) = U / ( n₁ · n₂ )

The common-language effect size. 0.5 means indistinguishable; 0.62 means a random treated user beats a random control 62% of the time.

Normal approximation
z = ( U − n₁n₂/2 ) / √( n₁n₂(n₁ + n₂ + 1) / 12 )

Used above roughly 20 per group, which every online experiment satisfies — see the Wilcoxon calculator.

Worked example

A marketplace tests a checkout change on revenue per session, 6,000 sessions per arm. Control averages £41.10 and the variant £44.60, an 8.5% lift that looks convincing. Both arms are heavily right-skewed: the median in each is close to £22, and the top 0.1% of sessions carry over a fifth of total revenue.

Control
mean £41.10, median £21.80, n = 6,000
Variant
mean £44.60, median £22.10, n = 6,000
Welch t-test
t = 1.71, p = 0.087
Mann-Whitney U
U = 18,720,000, z = 2.38, p = 0.017
P(variant > control)
0.520
Effect of dropping the top 6 sessions
t-test p moves to 0.31

The t-test says nothing detectable; the rank test says the variant is ahead. The two disagree, and the reason is visible in the last row.

The £3.50 gap in means is largely six sessions. Remove them and the t-test collapses to p = 0.31, which tells you the mean comparison was never resting on the other 11,994 observations. The rank test, unable to see magnitudes, finds a modest but consistent shift: a random variant session beats a random control session 52% of the time, up from the 50% of no effect. Both readings are true and they support different decisions. If the business case is total revenue, six sessions is far too thin a basis to ship on and the honest answer is that this test is underpowered for a skewed metric — cap the outliers and rerun, or plan for more traffic. If the case is that the checkout works better for the typical customer, the rank test supports it. What would be indefensible is running both and reporting whichever crossed 0.05.

Common misconceptions

The Mann-Whitney U test compares medians.
Only under an extra assumption. What it actually tests is whether a randomly drawn value from one group tends to exceed one from the other. That corresponds to a shift in medians when the two distributions have the same shape, and when they do not — say the treatment widens the spread — U can be significant while the medians are identical.
Non-parametric means it makes no assumptions.
It makes fewer, not none. Observations still have to be independent, and interpreting a result as a location shift still requires the two distributions to be similarly shaped. What it drops is the assumption about the sampling distribution of the mean, which is the one that matters for outlier-heavy data.
Rank-based tests are weaker, so only use one if the t-test's assumptions fail.
On skewed data it is often the more powerful of the two, precisely because it is not spending precision on a handful of extreme values. On symmetric data it retains about 95% of the t-test's power. The real reason to prefer a t-test is interpretive rather than statistical: it produces a difference in pounds, which a rank comparison cannot.

Frequently asked questions

When should I use the Mann-Whitney U test instead of a t-test?
When the outcome is heavily skewed and a small number of extreme values dominate the mean — revenue per user, order value, session duration. The practical check is to remove the top 0.1% of observations and see whether the conclusion changes. If it does, the mean comparison is resting on a handful of points and a rank-based test or a capped metric is the more honest analysis.
How do I report the size of the effect from a rank test?
Use the common-language effect size, U divided by the product of the two sample sizes, which is the probability that a random observation from one group exceeds one from the other. A value of 0.52 means a treated user beats a control user 52% of the time against a coin-flip baseline of 50%. Report the two medians alongside it, since stakeholders will reasonably want something in the units of the metric.
Is it better to cap outliers and run a t-test, or to use a rank test?
Capping is usually preferable when the business question is about totals, because it keeps the answer in currency and preserves most of the magnitude information. The condition is that the cap is chosen before seeing the results — a threshold picked after the fact is simply a choice about which answer to get. A rank test avoids that judgement entirely, which is why it is a good cross-check: if capping and ranking agree, the conclusion is not an artefact of either.
What happens when many observations are identical?
Tied values share an averaged rank, and a tie correction adjusts the variance in the normal approximation accordingly. With moderate ties this works fine. With very heavy ties — a metric that is zero for 90% of users, which is common for revenue per visitor — the test loses most of its ability to discriminate, and the better framing is usually two separate questions: did conversion change, and did spend among converters change.

Related terms

  • ANOVA

    One test for three or more variants — and the reason it deliberately refuses to say which one won.

  • Chi-square test

    The test for counts in a table — the standard SRM check, and the reason expected counts matter more than sample size.

  • Outlier

    The extreme value that decides your result — and why the rule for handling it must precede the data.

  • Paired t-test

    When every observation has a partner, pairing removes the differences between units and can cut the sample you need by an order of magnitude.

  • T-test

    The workhorse for comparing two averages — and the four assumptions that decide whether its answer means anything.

  • Bootstrap

    Resample your own data ten thousand times and watch the answer wobble — uncertainty for statistics with no formula.

  • Winsorization

    Pull the tail in rather than cutting it off — and choose the threshold before you see the results, or it is not a method.

Calculate it

  • Wilcoxon test

    Rank-sum (Mann-Whitney) and signed-rank tests, with the exact distribution for small samples.

  • Two-sample t-test

    Compare the average of two independent groups — plan the sample size, then test the result.

Knowing the term is the easy part

Applying it to a live measurement problem is the part that goes wrong. If you are designing an experiment, reading a result you do not trust, or trying to work out what your marketing actually caused, that is the work we do.