Tests · 7 min read

The Mann-Whitney U test, explained

The go-to test for comparing two groups when the data is skewed, has outliers, or is ordinal. What it really tests, and how to read and report it.

Advertisement
Updated November 2026 · Worked example included

The Mann-Whitney U test (also called the Wilcoxon rank-sum test) is the standard way to compare two independent groups when you cannot trust the assumptions of a t-test: the data is skewed, has outliers, or is measured on an ordinal scale such as pain scores or Likert ratings. Instead of comparing means, it compares the ranks of the observations. This guide explains what the test actually asks, works through a small example by hand, and shows how to report the result.

The question the test answers

If you pick one value at random from group A and one from group B, is A just as likely to be larger as B is? Under the null hypothesis the answer is yes (a 50/50 chance). A small p-value says one group tends to produce larger values than the other.

This is why the Mann-Whitney U test is often described loosely as a "test of medians". That description is only accurate when both groups have distributions of the same shape, one simply shifted relative to the other. If one group is tightly clustered and the other is widely spread, the test can be significant even when the medians are identical, or not significant when they differ. When you report the result, describe it as one group tending to have higher values, and show the distributions with a box or violin plot.

How it works: ranks instead of values

  1. Pool all observations from both groups and sort them from smallest to largest.
  2. Give each observation its rank: 1 for the smallest, 2 for the next, and so on. Tied values share the average of the ranks they would occupy.
  3. Add up the ranks belonging to group A. Call this RA.
  4. Convert it to the U statistic: UA = RA − nA(nA + 1) / 2. UA equals the number of pairs (one value from each group) in which the A value is larger.
  5. The two U values always add up to nA × nB. Most software reports the smaller one.

Because only the order of the values matters, a single extreme outlier has exactly the same influence as a value that is merely the largest. That is the source of the test's robustness.

A worked example

Suppose you measured reaction times (seconds) in two small groups:

GroupValuesn
A3, 5, 8, 94
B7, 10, 12, 14, 155

Sorted together, the ranks are: 3 (A, rank 1), 5 (A, 2), 7 (B, 3), 8 (A, 4), 9 (A, 5), 10 (B, 6), 12 (B, 7), 14 (B, 8), 15 (B, 9).

With samples this small and no ties, the p-value can be calculated exactly by listing every possible way to split the nine ranks into groups of four and five (126 ways). Only 4 of them give a U of 2 or less, so the one-sided probability is 4/126 = 0.032 and the two-sided p-value is 0.063.

Notice the lesson: group B looks clearly higher, yet p is above 0.05. With only nine observations, the test simply does not have enough information to rule out chance. That is not evidence that the groups are the same; it is a sign that the sample is too small. StatFlo uses this exact calculation when both groups have eight or fewer values and there are no ties, and a tie-corrected normal approximation otherwise.

When to use it (and when not to)

SituationMann-Whitney U?
Two independent groups, clearly skewed data (e.g. income, reaction times, cytokine levels)Yes, a good choice
Ordinal data: ratings, scores, gradesYes, the t-test's mean is hard to interpret here
A few extreme outliers you have no justification to removeYes
Roughly normal data with similar spreadWorks, but a t-test has slightly more power
The same subjects measured twice (before/after)No, use the Wilcoxon signed-rank test (see paired vs independent data)
Three or more groupsNo, use the Kruskal-Wallis test

A common worry is that non-parametric tests are "weaker". For normally distributed data, the Mann-Whitney U test is about 95% as efficient as the t-test, a small price. For heavy-tailed or skewed data it can be considerably more powerful than the t-test, because the t-test's standard deviation gets inflated by the extreme values.

Effect size: how big is the difference?

A p-value says whether a difference is detectable, not how large it is. Two effect sizes pair naturally with U:

Reporting a large effect with a non-significant p-value is perfectly legitimate and honest: it tells the reader the study was underpowered rather than that nothing happened.

How to report it

Because the test is based on ranks, report medians and interquartile ranges rather than means and standard deviations:

"Reaction times were longer in group B (median 12 s, IQR 10–14) than in group A (median 6.5 s, IQR 4.5–8.25), but the difference did not reach statistical significance (Mann-Whitney U = 2, nA = 4, nB = 5, exact two-sided p = 0.063; rank-biserial r = 0.80)."

The quartiles above use the same linear interpolation method as Excel's QUARTILE.INC; other software may give slightly different IQRs for very small samples, which is normal.

Running it in StatFlo

  1. Put each group in its own column with the group name in the first row.
  2. Upload the file, choose Box Plot or Violin Plot, and keep Show individual data points on.
  3. Under Statistical Test, choose Mann-Whitney U test and click Generate.
  4. The results show U, the p-value, the rank-biserial r effect size, and each group's n, median and IQR, followed by a written interpretation. Turn on Significance on graph to add an asterisk bracket.

Run a Mann-Whitney U test on your data.

Upload two columns, choose Mann-Whitney U, and get U, the p-value, medians and IQRs in seconds.

Open StatFlo