Mann-Whitney U Test — Definition, Formula & Example
The Mann-Whitney U test is a way to check whether values in one group tend to be larger than values in another group. It uses only the ranks of the data, so the data do not need to come from a normal distribution.
Given independent samples of sizes and , the Mann-Whitney U test (also called the Wilcoxon rank-sum test) ranks all observations together. It tests : both samples come from the same distribution. The statistic counts the pairs in which the observation from one sample exceeds the observation from the other, with each tied pair counting . Under , every assignment of ranks to the two groups is equally likely, which gives the exact null distribution of .
Key Formula
Where:
- = Sum of the ranks in group 1 and group 2, after you rank all observations together from smallest (rank 1) to largest
- = Sample sizes of the two groups
- = Number of cross-group pairs in which the group 1 value (or the group 2 value) is the larger one
Worked Example
Problem: A gardener grows 8 plants. Four get Fertilizer A and four get Fertilizer B. After 6 weeks, the heights in inches are A: 13, 15, 17, 20 and B: 8, 10, 12, 14. At the 0.05 level, is there evidence that Fertilizer A tends to produce taller plants?
Step 1: Rank all 8 heights together from smallest to largest: 8, 10, 12, 13, 14, 15, 17, 20. Group A holds ranks 4, 6, 7, 8, and group B holds ranks 1, 2, 3, 5. As a check, the ranks sum to .
Step 2: Compute both U values. They add to , as they should. means only one B plant (14 in.) is taller than an A plant (13 in.).
Step 3: Find the exact one-sided p-value. Under , all ways to assign 4 ranks to group B are equally likely. Only 2 of them give : perfect separation, and the single swap seen here.
Answer: Since , reject . There is convincing evidence that plants given Fertilizer A tend to grow taller than plants given Fertilizer B.
Why It Matters
Use this test in place of a two-sample t-test when samples are small and skewed or contain outliers. It also works when the data are only ordinal, such as 1-to-5 pain ratings in a medical study. For larger samples with no ties, is approximately normal with mean and standard deviation , so you can compute a z-score. Tied data, common with ratings, need a tie-corrected standard deviation.
Common Mistakes
Mistake: Stating that the Mann-Whitney U test always compares the two medians.
Correction: The test detects whether values from one group tend to be larger than values from the other. It reduces to a comparison of medians only when both distributions have the same shape and spread. Otherwise, state your conclusion as 'tends to produce larger values.'
