Mann-Whitney U Test

Question: Are the distributions of two independent groups significantly different? (Equivalently: if you randomly pick one observation from each group, what's the probability that group A's value exceeds group B's?)

Use it when: Two independent groups, normality is violated. This is the nonparametric analog of the independent t-test. Sometimes called the Wilcoxon rank-sum test — note: different from the Wilcoxon signed-rank test.

How it works:

  1. Combine all observations and rank them in ascending order (average ranks for ties).
  2. Sum the ranks for each group separately.
  3. Compute U statistics from the rank sums; take the smaller as the test statistic.

In Python: scipy.stats.mannwhitneyu(group1, group2)

Mann-Whitney U — Step-by-Step
Dataset
Step 1 — Combine all observations and rank them

Pool all observations from both groups into one list and sort them from smallest to largest. Assign ranks 1, 2, 3… to each value. When two values tie, average their ranks.

Combined ranking (low → high)
186msrank1
188msrank2
193msrank3
195msrank4
197msrank5
198msrank6
200msrank7
201msrank8
204msrank9
205msrank10
208msrank11
210msrank12
212msrank13
215msrank14
220msrank15
228msrank16
231msrank17
235msrank18
242msrank19
249msrank20
PositionGroupValue (ms)Rank
1Treatment1861
2Treatment1882
3Treatment1933
4Treatment1954
5Treatment1975
6Control1986
7Treatment2007
8Treatment2018
9Treatment2049
10Control20510
11Treatment20811
12Control21012
13Treatment21213
14Control21514
15Control22015
16Control22816
17Control23117
18Control23518
19Control24219
20Control24920
Step 1 of 3
Group A Group B

Walk through the three steps of the Mann-Whitney U test on real data. Switch datasets to see how the combined ranks and U statistics change.

Don't Confuse The Two

The Wilcoxon signed-rank test is for paired data. The Wilcoxon rank-sum test (Mann-Whitney U) is for independent groups. They share a name and similar mechanics but answer different questions. Check which one you need before running.