Mann-Whitney U Test Calculator

Compare two independent groups without assuming normal distributions. Calculates the U statistic, z-score, and two-tailed p-value with full working.

U
Z
P (2-TAILED)
N (TOTAL)
Provide data in both groups to calculate results.
Standard normal distribution with marked z-statistic and two-tailed rejection regions z = 0 −4 −2 0 2 4
Fig. 1 — Standard normal distribution showing the observed z-statistic (red line) and the two-tailed rejection region at α = .05 (shaded).

§1How this was calculated

§2The formula

U = min(U₁, U₂)
U₁ = R₁ − n₁(n₁+1)/2
U₂ = n₁n₂ − U₁
z = (U − μᵤ + c) / σᵤ
p = 2(1 − Φ(|z|))
R₁, R₂
Sum of ranks in group 1 and group 2
n₁, n₂
Sample sizes
μᵤ
Expected value of U under H₀ = n₁n₂/2
σᵤ
Standard deviation, adjusted for ties
c
Continuity correction (0.5 toward the mean)
Φ
Cumulative standard normal distribution

§3Worked example

Suppose you have two groups, each with n = 5 values, no ties:

Rank Value Group
1 1.8 A
2 2.3 A
3 3.2 A
4 4.1 B
5 4.9 B
6 5.0 A
7 5.2 B
8 5.8 B
9 6.1 B
10 6.3 A

Group A: 1.8, 2.3, 3.2, 5.0, 6.3 → Ranks: 1, 2, 3, 6, 10 → R₁ = 22
Group B: 4.1, 4.9, 5.2, 5.8, 6.1 → Ranks: 4, 5, 7, 8, 9 → R₂ = 33
Total N = 10; check: 22 + 33 = 55 = 10(11)/2 ✓

U₁ = 22 − 5(6)/2 = 22 − 15 = 7
U₂ = 5 × 5 − 7 = 25 − 7 = 18
U = min(7, 18) = 7

μᵤ = 5 × 5 / 2 = 12.5
No ties, so σᵤ = √(5 × 5 × 11 / 12) = √(22.92) ≈ 4.79
z = (7 − 12.5 + 0.5) / 4.79 = −5 / 4.79 ≈ −1.04
p = 2(1 − Φ(1.04)) ≈ 2(1 − 0.851) ≈ 0.298

Conclusion: Fail to reject H₀ at α = .05. There is insufficient evidence that the distributions differ.

§4Assumptions & when this test is right

Independent samples

The two groups must be independent—observations in one group should not influence the other. If your data are paired (e.g. before and after on the same subjects), use the Wilcoxon signed-rank test instead.

What it tests

The Mann-Whitney U test does not strictly compare medians; it tests whether one distribution tends to have larger values than the other (stochastic dominance). Only when the two distributions have similar shapes is the result directly interpretable as a median difference. Always inspect your data visually (histograms or box plots) alongside the test.

When to use Mann-Whitney instead of t-test

The Mann-Whitney U test is the non-parametric alternative to the independent-samples t-test. Choose Mann-Whitney when:

  • Your data are ordinal (ranks, rankings) or continuous but severely non-normal.
  • Outliers or skewness are substantial.
  • Sample sizes are very small and normality cannot be verified.

If your data are roughly normal, the t-test is slightly more powerful. See the t-test calculator for a parametric alternative and the test selection guide for more detail.

Three or more groups?

For three or more independent groups, use the Kruskal-Wallis test, which is the multi-group generalization of Mann-Whitney.

§5FAQ

What is the Mann-Whitney U statistic?

U is the count of all pairs (one value from group A, one from group B) in which the group-A value is smaller than the group-B value. It ranges from 0 (all A values are smaller) to n₁ × n₂ (all A values are larger). Under the null hypothesis that the two distributions are identical, U has a known distribution, which we approximate with the normal distribution for larger samples.

Why use ranks instead of raw data?

By converting to ranks, the test ignores the absolute scale of your measurements and focuses only on their relative order. This makes the test robust to outliers and to non-normal distributions, which is why Mann-Whitney is called non-parametric.

What does the continuity correction do?

The continuity correction (adding or subtracting 0.5 to U) improves the fit of the discrete distribution of U to the continuous normal distribution, especially for small samples. It moves the z-score slightly toward the mean, making the p-value slightly less extreme (more conservative).

How are tied values handled?

When two or more values are equal, they are assigned the average of their ranks (e.g. if three values tie for ranks 5, 6, 7, each gets rank 6). The standard deviation is then adjusted using a tie-correction term. This calculator applies that correction automatically.

Is this a one-tailed or two-tailed test?

This calculator always performs a two-tailed test, testing the null hypothesis that the two distributions are identical against the alternative that they differ in any direction. The p-value shown is the two-tailed p-value. If you need a one-tailed test (only testing whether one group is larger), divide the displayed p-value by 2, but document this decision clearly.

Why does my result disagree with a textbook table?

This calculator uses a normal approximation to the exact distribution of U. For very small samples (both n ≤ 20), exact critical-value tables are more accurate. Consult references such as Hollander, Wolfe & Chicken (Nonparametric Statistical Methods) or similar statistical tables. The calculator alerts you when both samples are small.

§6Sources