The Mann–Whitney U test (also called the Wilcoxon–Mann–Whitney test) is the standard non-parametric alternative to the two-sample t-test. Instead of comparing means, it pools both samples, ranks all the values from smallest to largest and checks whether one sample tends to get the higher ranks. Because it uses ranks, it is not thrown off by outliers or skewed distributions and works with ordinal data such as ratings.
U₁ counts how many of the n₁ × n₂ possible pairs have the value from sample 1 above the value from sample 2 (ties count half). If the two populations are the same, U₁ should be close to n₁n₂/2. Very small or very large values signal a shift. U₁ ÷ (n₁n₂) is itself a useful effect size: the probability that a random value from sample 1 exceeds one from sample 2.
For small samples without ties the calculator uses the exact distribution of U, built by counting every possible arrangement of ranks. With ties or larger samples it uses the normal approximation with a tie correction and, optionally, a continuity correction – the same choices R and SciPy offer.
How to use the Mann–Whitney U Test Calculator
- Sample 1
- Sample 2
- Alternative hypothesis
- p-value method
- Continuity correction (normal approximation)
- Significance level (α)
Everything is calculated in your browser, so results appear instantly and nothing you type is sent to a server.
How it works
Paste the two samples. The calculator ranks all values together (tied values share the average rank), adds the ranks of each sample, converts them to U₁ and U₂ and finds the p-value from the exact distribution or from z. It also reports the critical U for exact tests, the rank-biserial correlation and the median of all pairwise differences.
Worked example
Sample 1 (8 values: 3.1, 4.5, 2.8, 5.0, 4.1, 3.9, 4.8, 5.6) and sample 2 (7 values: 2.4, 3.0, 2.2, 3.3, 2.9, 3.6, 2.7) are ranked together from 1 to 15. Sample 1 collects the ranks 7, 12, 4, 14, 11, 10, 13 and 15, so R₁ = 86.
U₁ = 86 − 8 × 9 ÷ 2 = 50 and U₂ = 8 × 7 − 50 = 6, so U = 6. The exact two-tailed p-value is 0.0093 and the critical U at α = 0.05 is 10, so we reject H₀: sample 1 tends to have larger values. The normal approximation gives z = 2.49 and p = 0.0128. The probability that a sample 1 value beats a sample 2 value is 50 ÷ 56 = 0.89.
Mann–Whitney U or t-test?
| Situation | Better choice |
|---|---|
| Roughly normal data, any size | Two-sample t-test (Welch) |
| Small samples with outliers or skew | Mann–Whitney U |
| Ordinal data (Likert ratings) | Mann–Whitney U |
| Paired observations | Wilcoxon signed-rank test |
| Three or more groups | Kruskal–Wallis test |
Formula
U₁ = R₁ − n₁(n₁ + 1)/2 · U₂ = n₁n₂ − U₁ · U = min(U₁, U₂) · μ_U = n₁n₂/2 · σ_U = √(n₁n₂/12 × [(N + 1) − Σ(t³ − t)/(N(N − 1))]) · z = (U₁ − μ_U ∓ 0.5) ÷ σ_U
Worked example
Inputs — Sample 1: 3.1, 4.5, 2.8, 5.0, 4.1, 3.9, 4.8, 5.6; Sample 2: 2.4, 3.0, 2.2, 3.3, 2.9, 3.6, 2.7; Alternative hypothesis: The samples differ (two-tailed); p-value method: Automatic (exact when possible); Continuity correction (normal approximation): Yes; Significance level (α): 0.05.
Results — p-value = 9.32e-3; U statistic (smaller of U₁ and U₂) = 6; U₁ (sample 1) = 50; U₂ (sample 2) = 6; Decision = Reject H₀ at α = 0.05 – p = 0.0093 ≤ 0.05; the two distributions differ in location.; Method used = Exact distribution of U (no ties).
Key terms
- Rank
- A value's position when all observations are sorted; ties share the average position.
- U statistic
- The number of (sample 1, sample 2) pairs in which the sample 1 value is larger, counting ties as ½.
- Exact distribution
- The probability of every possible U under H₀, obtained by counting rank arrangements.
- Hodges–Lehmann estimator
- The median of all pairwise differences x − y, a robust estimate of the shift between groups.
Frequently asked questions
When should I use the Mann–Whitney U test instead of a t-test?
When the samples are small and clearly non-normal, contain outliers, or the data are ordinal (ratings, ranks). For roughly normal data the t-test is slightly more powerful.
Does the Mann–Whitney test compare medians?
Only if both distributions have the same shape. In general it tests whether values from one population tend to be larger than values from the other.
What is the critical value of U for n₁ = 8 and n₂ = 7?
10 for a two-tailed test at α = 0.05: reject H₀ when the smaller U is 10 or less. In the default data U = 6, so the result is significant.
How are ties handled?
Tied values get the average of the ranks they span, and the variance of U is reduced by the tie correction Σ(t³ − t). The exact distribution assumes no ties, so the normal approximation is used when ties exist.
Is the Mann–Whitney U test the same as the Wilcoxon rank-sum test?
Yes – they are equivalent. Wilcoxon's W is the rank sum R₁, and U₁ = W − n₁(n₁ + 1)/2, so the p-values match.
What sample size do I need?
The test works from very small samples, but with n₁ = n₂ = 3 no result can reach two-tailed p ≤ 0.05. Aim for at least 5 or 6 per group.
Why does my p-value differ from SPSS?
SPSS reports the asymptotic p-value without continuity correction by default, plus an exact p-value for small samples. Set the method and continuity options here to match.