Ad Space — Top Banner

Mann-Whitney U Test Formula

Learn the Mann-Whitney U test — a non-parametric test that compares two independent groups without assuming a normal distribution.
Includes formula, worked example, and interpretation.

The Formula

U1 = n1n2 + n1(n1+1)/2 − R1
U2 = n1n2 + n2(n2+1)/2 − R2

The Mann-Whitney U test (also called the Wilcoxon rank-sum test) determines whether two independent samples come from the same distribution. Unlike the t-test, it does not assume that the data is normally distributed. It works by ranking all values across both groups combined, then comparing where each group's values tend to fall in that ranking.

The test statistic U represents the number of times a value from one group ranks ahead of a value from the other group. A small U (relative to its maximum possible value of n1 × n2) suggests the groups differ significantly.

Variables

SymbolMeaning
U1Mann-Whitney U statistic for group 1
U2Mann-Whitney U statistic for group 2 (note: U1 + U2 = n1 × n2)
n1Sample size of group 1
n2Sample size of group 2
R1Sum of ranks assigned to group 1 observations
R2Sum of ranks assigned to group 2 observations
U (test statistic)The smaller of U1 and U2 — compared to critical values

Step-by-Step Procedure

  1. Combine all values from both groups into one list.
  2. Rank all values from smallest (rank 1) to largest. For tied values, assign the average of the ranks they would have received.
  3. Separately sum the ranks for each group to get R1 and R2.
  4. Calculate U1 and U2 using the formulas above.
  5. The test statistic U = min(U1, U2).
  6. Compare U to the critical value from a Mann-Whitney U table at your chosen significance level (α = 0.05 is typical).
  7. If U ≤ critical value, reject the null hypothesis — the groups differ significantly.

Example

Group A (treatment) scores: 85, 72, 90, 78. Group B (control) scores: 65, 70, 75, 68. Is there a significant difference? (n1 = 4, n2 = 4)

Step 1 — Combine and rank all 8 values: 65(1), 68(2), 70(3), 72(4), 75(5), 78(6), 85(7), 90(8)

Step 2 — Group A ranks: 85→7, 72→4, 90→8, 78→6. R1 = 7+4+8+6 = 25

Step 3 — Group B ranks: 65→1, 70→3, 75→5, 68→2. R2 = 1+3+5+2 = 11

Step 4 — U1 = 4×4 + 4(4+1)/2 − 25 = 16 + 10 − 25 = 1

U2 = 4×4 + 4(4+1)/2 − 11 = 16 + 10 − 11 = 15

Check: U1 + U2 = 1 + 15 = 16 = n1 × n2 = 4 × 4 ✓

Test statistic U = min(1, 15) = 1

At α = 0.05 with n1 = n2 = 4, the critical value is 1. Since U ≤ 1, we reject H0. Group A scores are significantly higher than Group B (p < 0.05).

When to Use the Mann-Whitney U Test

  • Data is ordinal (ranked categories) rather than continuous
  • The distribution is skewed or you cannot assume normality
  • Small sample sizes where the Central Limit Theorem does not apply
  • Comparing patient pain scores, Likert-scale survey responses, or ranked preferences
  • Any time you would use a t-test but the normality assumption is violated

Large-Sample Approximation

When both samples have more than about 20 observations, the U statistic follows an approximately normal distribution:

z = (U − μU) / σU    where μU = n1n2/2    and    σU = √(n1n2(n1+n2+1)/12)

The resulting z-score can then be compared to the standard normal distribution (z > 1.96 for α = 0.05, two-tailed).


Ad Space — Bottom Banner

Embed This Calculator

Copy the code below and paste it into your website or blog.
The calculator will work directly on your page.