Mann-Whitney U Test Calculator

Mann–Whitney U Test Calculator

Compare two independent groups without assuming normal data. Get U, an exact p-value for small samples (normal approximation for large or tied ones), and the chance a value from one group beats the other.

U₁ = R₁ − n₁(n₁ + 1) ÷ 2

The groups can be different sizes. With no ties and up to 30 per group, the p-value is exact.

Enter the values for both groups

What is the Mann–Whitney U Test?

The Mann–Whitney U test compares two independent groups using only the order of the values, not their sizes. It asks whether values from one group tend to be larger than values from the other.

U counts how many times a value from one group beats a value from the other across every possible pairing. If the groups are alike, each wins about half the pairings; a U near zero or near n₁ × n₂ means one group almost always wins.

Because it uses ranks, outliers and skewed data don't throw it off. That makes it the usual alternative to the two-sample t-test for small samples, ratings or data that clearly aren't normal.

Mann–Whitney U Formula

As defined by Mann and Whitney (1947); tie correction as in Hollander, Wolfe and Chicken. See Sources.

1. Rank everything together

Smallest value = rank 1; tied values share their average rank

2. Turn rank sums into U

U₁ = R₁ − n₁(n₁ + 1) ÷ 2 · U₂ = n₁n₂ − U₁
U = min(U₁, U₂)

3. p-value

Exact: count the arrangements of ranks giving U this small
Large samples: z = (U₁ − n₁n₂/2) ÷ √(n₁n₂(N + 1)/12)

Worked Example: Reaction Times With and Without Caffeine

Given:
Errors in a timed task: with caffeine 12, 15, 9, 20, 17; without 22, 25, 19, 30, 28, 24.
Step 1:
Rank all 11 values; caffeine group's ranks:
9 → 1, 12 → 2, 15 → 3, 17 → 4, 20 → 6 · R₁ = 16
Step 2:
U:
U₁ = 16 − 5 × 6 ÷ 2 = 1 · U₂ = 30 − 1 = 29
Step 3:
Exact p:
Only 2 of 462 arrangements give U ≤ 1 → p = 2 × 2/462 = 0.0087
Result:
U = 1, p = 0.0087

In 29 of the 30 possible caffeine-versus-no-caffeine pairings, the caffeine score was lower. Only the 20 beats the 19.

Smallest Significant Results for Small Groups

The exact two-sided p-value when one group is completely above the other (U = 0). With very small groups, even perfect separation can't reach 5%.

Exact p-value for complete separation by group size
Group sizesBest possible pCan reach 5%?
2 and 20.3333No
3 and 30.1No
3 and 40.0571No
4 and 40.0286Yes
5 and 50.0079Yes

Common Mann–Whitney Mistakes

  • Calling it a test of medians. It tests whether one group tends to have larger values. Only when the two distributions have the same shape does that amount to a difference in medians.
  • Using it on paired data. Before/after on the same people needs the Wilcoxon signed-rank test instead.
  • Expecting significance from tiny groups. With 3 in each group, the smallest possible p is 0.1.
  • Comparing U from different software directly. Some programs report U₁, some the smaller U, and R reports W = U₁. Check which one you have.

Mann–Whitney U Test FAQs

Is Mann–Whitney the same as the Wilcoxon rank-sum test?

Yes, they’re equivalent. Wilcoxon uses the rank sum W, Mann and Whitney the count U, and W = U₁ + n₁(n₁ + 1)/2. The p-values are identical.

When should I use it instead of a t-test?

With small samples that look clearly non-normal, with outliers, or with ordinal data such as ratings.

What does the “chance of beating” figure mean?

It’s U₁ ÷ (n₁n₂), the probability of superiority: the share of all cross-group pairings won by group 1. 50% means no tendency either way; the caffeine example gives 3.3%.

How are ties handled?

Tied values share their average rank, and the normal approximation uses a variance correction for ties. The exact p-value is used only without ties.

Do the groups need equal sizes?

No. Any sizes work, though small groups give little power.

Does it assume anything?

Independent observations, and values that can at least be ordered. It doesn’t assume normality.

How do I run it in R?

wilcox.test(group1, group2). R reports W, which equals U₁ here.

What about three or more groups?

Use the Kruskal–Wallis test, the rank-based counterpart of one-way ANOVA.

Sources

Related Tools