How to run a Mann-Whitney test
- Copy a group name column and a measurement column together with the header (one column per group also works).
- Select the response column and the group column (2 levels), or select two columns with 'Two numeric columns'. Leave the p-value method on automatic in most cases.
- Press Analyze and check the p-value, the location shift (HL estimate) and the effect size in the test summary.
Worked example with sample data
The sample data are the impurity levels (ppm) of 12 lots of raw material from each of two suppliers (Supplier A and Supplier B). The Supplier column is the group column and the Impurity column the response column.
The test summary shows U = 22 and a p-value of 0.004265, so the impurity levels of the two suppliers differ significantly. The medians are 14.5 ppm for Supplier A and 25 ppm for Supplier B, and the mean ranks (8.333 vs 16.67) also show that Supplier B's values are larger overall.
The location shift (Hodges-Lehmann estimate) is -10 ppm (confidence interval -17 to -5), meaning Supplier A's material is typically about 10 ppm cleaner than Supplier B's. The effect size (rank-biserial correlation) of -0.6944 is a large effect with an absolute value above 0.5; the negative sign means group 1 (Supplier A) has the smaller values.
In the ECDF chart, Supplier A's step line stays to the left of Supplier B's from start to finish, so whatever threshold you pick, a larger share of Supplier A's lots fall below it. Both suppliers have right-skewed distributions (skewness 1.24 and 1.41) with one outlier each, so comparing ranks instead of means is the safer choice.
How it is calculated
Both groups are ranked together, and U = R1 - n1(n1+1)/2 is computed from the rank sum R1 of group 1.
As in SciPy's mannwhitneyu, the automatic method uses the normal approximation (with tie and continuity corrections) when both groups have more than 8 values or there are ties, and the exact distribution otherwise.
Effect size and location shift
The rank-biserial correlation r = 2U/(n1·n2) - 1 lies between -1 and 1 and approaches 1 the more strongly group 1 tends to have larger values than group 2.
The location shift is the Hodges-Lehmann estimate, the median of all pairwise differences (group 1 - group 2), with its confidence interval.
What the result shows
The results table (N, median and mean rank by group), the test summary, a box plot, a violin plot, an individual value plot and the ECDF (cumulative distribution).
How to read the Mann-Whitney test result
- If the p-value is below the significance level, the locations of the two groups differ. The interpretation tells you which group has the higher median.
- For the effect size r, absolute values of about 0.1, 0.3 and 0.5 are commonly used as small, medium and large effects.
- In the ECDF, if one group's step line stays to the right of the other's, that group has larger values overall.
Frequently asked questions
How is it different from the 2-sample t test?
The t test compares means; Mann-Whitney compares locations through ranks. It is more stable when the distributions are skewed or contain outliers.
Is it the same as the Wilcoxon rank-sum test?
Yes. The Mann-Whitney U test and the Wilcoxon rank-sum test are the same test with the same p-value.
When is the exact calculation used?
With small samples and no ties, the automatic method uses the exact distribution. If you choose 'Exact' when there are ties, no tie correction is made.