How to Run the Mann-Whitney U Test

Tests whether two independent groups differ, working from ranks rather than the values themselves. It assumes no normal distribution, so it holds up with outliers and with ordinal data, standing in where a t-test is hard to justify.

This tests whether two independent groups differ, using ranks rather than the values themselves. Unlike a t-test, it does not assume the populations are normally distributed.

The two groups are pooled, sorted and ranked together. Writing R1R_1 for the sum of the ranks in group A, the statistic is as follows.

U=R1n1(n1+1)2U = R_1 - \dfrac{n_1(n_1+1)}{2}

UU counts how many pairs have a group A value above a group B value. If the groups do not differ, UU should land near n1n2÷2n_1 n_2 \div 2. Given a reasonable sample, UU is well approximated by a normal distribution.

Example

With group A at 12, 15, 18, 20, 25, 28, 31 and group B at 5, 7, 9, 10, 11, 14, 16, the rank sum for A is 74 and UU is 3. That gives z=2.75z = -2.75 and a p-value of 0.006, so the groups differ at the 5% level.

When to use it

It suits data with outliers, ordinal data such as a five-point satisfaction scale, and anything hard to treat as normal. Working from ranks keeps extreme values from dragging the result about.

Notes

Repeated values share a rank. They are given the average rank and the variance is corrected for it; without that correction the test finds significance too readily.

The normal approximation weakens in small samples. Around ten in each group is a reasonable minimum.