Mann–Whitney U test calculator
Paste two independent samples, get the ranks, U and the p-value.
Separate numbers with commas, spaces or new lines. Use a point for decimals.
What does the Mann–Whitney U test do?
It compares two independent samples without assuming a normal distribution. All values are ranked together from smallest to largest, and the test asks whether one sample’s ranks are higher than chance would explain. It is also called the Wilcoxon rank-sum test; R’s wilcox.test and SciPy’s mannwhitneyu compute the same statistic. When the two distributions have the same shape, it compares their medians; otherwise it tests whether a value from one group tends to be larger than a value from the other.
How are U1, U2 and U calculated?
Add up the ranks of sample 1 (R1). Then U1 = R1 − n1(n1 + 1) ÷ 2, U2 = n1n2 − U1, and U is the smaller of the two. In the Wikipedia tortoise-and-hare example (6 and 6 runners), the rank sums are 32 and 46, so U = 32 − 21 = 11 for the tortoises and 46 − 21 = 25 for the hares; they add up to n1n2 = 36. Tied values get the average of the ranks they share.
When is the p-value exact, and when is it a normal approximation?
The calculator uses the exact distribution of U when there are fewer than 50 values in total and no ties, the same rule as R’s wilcox.test up to version 4.5 (R 4.6.0 can also give an exact p-value when there are ties; this calculator uses the normal approximation in that case). Otherwise it uses z = (|U1 − n1n2 ÷ 2| − 0.5) ÷ σ, where σ² = (n1n2 ÷ 12) × [(N + 1) − Σ(t³ − t) ÷ (N(N − 1))], N = n1 + n2 and t is the size of each group of tied values; the 0.5 is the continuity correction, which you can switch off, and the sign of z shows which sample ranks higher. For SciPy’s documentation example (males 19, 22, 16, 29, 24 and females 20, 11, 17, 12) U1 = 17 and the two-sided p-value is 0.1111 exact, 0.1113 with the correction and 0.0864 without it.
What happens with tied values?
Tied values share the average of their ranks, and the standard deviation of U is reduced by the tie term above. An exact p-value is not available when there are ties, so the normal approximation is used; with many ties or very small samples treat the p-value as approximate.
What effect size should I report?
Two common ones come from U. The rank-biserial correlation is r = 2U1 ÷ (n1n2) − 1, from −1 to +1 (its size is 1 − 2U ÷ (n1n2), the simple formula of Wendt, 1972; Kerby, 2014 explains the sign). The common-language effect size, U1 ÷ (n1n2), is the probability that a randomly chosen value from sample 1 is larger than one from sample 2, counting ties as half (McGraw and Wong, 1992). In the SciPy example above, U1 = 17 of 20 pairs gives 85% and r = 0.70.
Should I use this or a t-test?
Use the Mann–Whitney test when the data are ranks or ordered categories, when the samples are small and clearly skewed, or when outliers matter. If the data look roughly normal, the t-test calculator compares the means. For the same people measured twice, use the paired t-test calculator (or a signed-rank test) instead, because this test needs independent samples.
Sources: H. B. Mann and D. R. Whitney, Annals of Mathematical Statistics 18 (1947) 50–60; F. Wilcoxon, Biometrics Bulletin 1 (1945) 80–83; documentation of R (stats::wilcox.test) and SciPy (scipy.stats.mannwhitneyu); Wikipedia, “Mann–Whitney U test”; H. W. Wendt (1972); D. S. Kerby, “The simple difference formula,” Comprehensive Psychology 3 (2014); K. O. McGraw and S. P. Wong, Psychological Bulletin 111 (1992) 361–365. Related: t-test calculator, paired t-test calculator, effect size calculator and p-value calculator.