Mann-Whitney U Test
calculator.
Compare two independent groups by rank, with no need for normal data.
| # | Group 1 | Group 2 |
|---|---|---|
| 1 | ||
| 2 | ||
| 3 | ||
| 4 | ||
| 5 | ||
| 6 | ||
| 7 | ||
| 8 |
- p-value
- 0.0033
- Effect size r (large)
- 0.736
- Rank-biserial
- −0.891
A value from group 1 lands below a value from group 2 more often than not: it wins 5.5% of pairs, with ties counted as half. At α = 0.05 the groups differ. There are ties, so the p-value uses the tie-corrected normal approximation.
U₁ if the groups were equal
If the groups came from the same distribution, U₁ would center on 32 with a standard deviation of 9.515. Yours is 3.5, and the shaded tail beyond it shows how unusual that is. This curve is the normal approximation.
Where each group sits
Medians are 18.5 and 29.5. The test reads the whole spread of the dots, not only those two lines.
Reading the size of the result
- Effect size r
- 0.736, large
- Bands for r
- 0.1 small, 0.3 medium, 0.5 large
- Two-sided critical U at α = 0.05
- Not for tied data
- Medians
- 18.5 and 29.5
The p-value with one value left out
| Leave out | p-value | Change |
|---|---|---|
| 12 from group 1 | 0.0054 | +0.0022 |
| 18 from group 1 | 0.0054 | +0.0022 |
| 23 from group 1 | 0.0038 | +0.0005 |
| 15 from group 1 | 0.0054 | +0.0022 |
| 27 from group 1 | 0.0026 | −0.0007 |
| 19 from group 1 | 0.0054 | +0.0022 |
| 14 from group 1 | 0.0054 | +0.0022 |
| 22 from group 1 | 0.0022 | −0.0011 |
If one value moves p across your α, say so when you report the result.
Every value and its rank
| Group | Value | Rank | Tied |
|---|---|---|---|
| Group 1 | 12 | 1 | No |
| Group 1 | 14 | 2 | No |
| Group 1 | 15 | 3 | No |
| Group 1 | 18 | 4 | No |
| Group 1 | 19 | 5 | No |
| Group 1 | 22 | 6.5 | Yes |
| Group 2 | 22 | 6.5 | Yes |
| Group 1 | 23 | 8 | No |
Working
- 1Rank both groups togetherN = 16, and tied values share their average rank
- 2Add the ranks in each groupR₁ = 39.5R₂ = 96.5
- 3Take off the smallest possible rank sumU₁ = 39.5 −8 × 92= 3.5
- 4U₂ is what is left of the pairsU₂ = 64 − 3.5 = 60.5
- 5Keep the smaller as UU = 3.5
- 6Find the mean and tie-corrected spread of Uμ =642= 32, σ = 9.5149
- 7Use the normal approximationz = −2.943p = 0.0033
- 8Check: the totals come backR₁ + R₂ = 136, the total of ranks 1 to 16U₁ + U₂ = 64, the 64 pairs
How it's worked out
The Mann-Whitney U test, also called the Wilcoxon rank-sum test, asks whether a value from one group tends to be larger than a value from the other. It uses only the order of the values, so it copes with skewed data, outliers and rating scales, where a two-sample t test can mislead. For three or more groups, use the Kruskal-Wallis test.
You rank all the values together, smallest first, and tied values share their average rank. R₁ is the sum of the ranks in group 1, and n₁ and n₂ are the group sizes.
U₁ equals the number of pairs, one value from each group, in which the group 1 value is larger, with ties counted as half. So estimates the chance that a group 1 value beats a group 2 value. The tool reports the smaller of the two as U, as tables do.
Here N is the total count, and each t is the size of a set of tied values, so c is just N + 1 when nothing ties. With no ties and neither group above 50 values, the tool counts every possible arrangement of the ranks for an exact p-value, as R's wilcox.test does for samples of this size. Otherwise it uses z from the mean and spread above, with an optional 0.5 continuity correction.
Three effect sizes go beside p. r is , the rank-biserial correlation is , and the probability of superiority is . The Hodges-Lehmann shift is the median of all the differences between the two groups, not the difference between their medians.
Worked examples
Permeability of tissue, a published data set
R's documentation for wilcox.test uses data from Hollander and Wolfe: permeability constants at term against those at 12 to 26 weeks, ten values against five, asking whether the first group is larger.
The first group's ranks add to 90, so U₁ is 35 and the exact one-sided p-value is 0.1272. The rank-biserial correlation is 0.4, a tendency for group 1 to be larger that a sample this small cannot confirm. The smaller U here is 15, and a two-sided test at 0.05 with these sizes would need 8 or less.
Reaction times, eight people per group
Group 1's times run from 12 to 27 and group 2's from 22 to 35, so they overlap only a little. R₁ is 39.5, U₁ is 3.5 and U₂ is 60.5.
The two groups share the value 22, which is a tie, so the normal approximation applies: z = −2.943 and the two-sided p is 0.0033. The effect size r is 0.736, which reads as large. The Hodges-Lehmann shift is 10.5, so group 1 runs about that much lower.
A single tie is enough to switch off the exact count. No single value changes the verdict at 0.05: leaving one out gives a p-value of at most 0.0054, when 12 goes from group 1.
Pain ratings with many ties
Two groups of nine people rate pain from 1 to 7. Scores repeat often, as they do on any rating scale, so most ranks are shared averages.
U is 6.5. The tie-corrected standard deviation of U is 11.095, z is −3.02 and the two-sided p is 0.0025. Group 1 beats group 2 in only 8% of pairs, with ties counted as half, so the scores in group 2 clearly tend to run higher.
Reading your result
U. A U₁ near half of means the groups overlap evenly. A U₁ near 0 or near means one group almost always wins.
Effect size r. Cohen's thresholds call 0.1 small, 0.3 medium and 0.5 large. The same paper warns that these labels are only heuristics, and they may not match what matters in practice.
Rank-biserial correlation. The share of pairs that favor group 1 minus the share that favor group 2, from −1 to 1. It keeps the direction, which r does not.
Exact critical U. With no ties and a two-sided test, the smaller U must be at or below the value in this table, computed from the same exact counts. With four per group, even complete separation has a two-sided p of 0.029, so tiny samples can barely reach significance at 0.05 and cannot reach it at 0.01.
| Per group | α = 0.05 | α = 0.01 |
|---|---|---|
| 4 | 0 | None |
| 5 | 2 | 0 |
| 6 | 5 | 2 |
| 8 | 13 | 7 |
| 10 | 23 | 16 |
| 15 | 64 | 51 |
| 20 | 127 | 105 |
Common mistakes
- Calling it a test of medians without checking. GraphPad's note explains that the test compares mean ranks. It reads as a test of medians only if the two distributions have the same shape, shifted. Unequal spreads can give a significant result even when the medians match.
- Using it on paired data. Each value must come from a different subject and the groups must be unrelated. For before and after readings on the same people, use the Wilcoxon signed-rank test.
- Reporting only the p-value. A large sample makes tiny differences significant. Give an effect size and the Hodges-Lehmann shift beside it.
- Expecting an exact p-value with ties. Here, one tied value switches the test to the normal approximation. Other software differs: SciPy's automatic choice is exact only when a sample has 8 or fewer values and there are no ties, so a small gap between programs is normal.