Mann-Whitney Test (Mann-Whitney U, Rank-Sum Test)

Compare two groups whose data are skewed or contain outliers, such as impurity levels or waiting times. Instead of the 2-sample t test, the location difference is tested with ranks, with an effect size, a location shift estimate and six charts comparing the two distributions.

1Data Table

Paste a table copied from Excel into a cell (Ctrl+V). Click a column header (A, B…) before pasting to use the first line as column names. Double-click a header to rename it, right-click to insert/delete rows and columns, and formulas such as =A1*2 work too.

2Mann-Whitney Test Options

Data input
P-value method

How to run a Mann-Whitney test

  1. Copy a group name column and a measurement column together with the header (one column per group also works).
  2. 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.
  3. 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.

ECDF (cumulative distribution) of Supplier A and Supplier B impurity - the further left the step line, the smaller the values
ECDF (cumulative distribution) of Supplier A and Supplier B impurity - the further left the step line, the smaller the values

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.

Other chart tools