Chip Foundry Services Request Assessment

Mann-Whitney U

The Mann-Whitney U test (also called the Wilcoxon rank-sum test) compares two independent groups without assuming a normal distribution. It asks whether a randomly chosen value from one group tends to be larger than a randomly chosen value from the other. It is the rank-based partner of the two-sample t-test and is the usual choice for skewed data, outliers and ordinal ratings.

The procedure:

Two independent groups
sizes n1 and n2, any distribution shape
Rank all n1 + n2 values togetherties get the average of their ranks
Sum the ranks of group 1
R1
U = R1 - n1(n1 + 1)/2
count of pairs won by group 1
Compare with the null distribution of U
exact if small, normal if large
Report p, plus an effect size
probability of superiority or Hodges-Lehmann shift

The statistic. Pool both groups, rank every value from smallest to largest, and let $R_1$ be the sum of the ranks of group 1. The U statistic for each group counts, over all pairs with one value from each group, how often that group's value is the larger one, with ties counted as one half:

$$U_1=R_1-\frac{n_1(n_1+1)}{2},\qquad U_2=n_1n_2-U_1$$

The two always add to $n_1n_2$, and the test statistic is the smaller of them. If the groups do not differ, $U$ is centred at $n_1n_2/2$; a very small or very large value signals that one group tends to be larger.

Worked example. This continues the etch-rate data from the non-parametric overview. Recipe A gives $10.1,\,10.8,\,11.2,\,11.6,\,12.0,\,12.4$ and recipe B gives $11.9,\,12.6,\,13.1,\,13.5,\,14.2,\,41.0$. In the pooled ranking, A holds ranks $1,2,3,4,6,7$ with $R_1=23$, so $U_1=23-21=2$ and $U_2=36-2=34$. Recipe B beat recipe A in $34$ of the $36$ possible pairs.

With $6$ wafers per group there are $\binom{12}{6}=924$ equally likely ways the ranks could split between groups if the recipes did not differ. Only $4$ of them give $U\le2$, with counts $1,\,1,\,2$ for $U=0,1,2$, and by symmetry another $4$ give $U\ge34$. The exact two-sided p-value is $8/924\approx0.0087$, which matches scipy.

The exact null distribution of U (6 vs 6 wafers) all 924 equally likely ways to split ranks 1 to 12 between two groups; observed U = 2 0 20 40 0 6 12 18 24 30 36 U statistic (number of pairs in which A beats B) observed U = 2 4 of 924 arrangements are this low the mirror tail (U = 34 or more) two-sided p = (4 + 4) / 924 = 0.0087 | normal approximation gives 0.0104 the exact count is preferred for small samples; the approximation is for larger ones

Large samples. Counting becomes impractical as the groups grow, so software switches to a normal approximation with mean and standard deviation:

$$\mu_U=\frac{n_1n_2}{2},\qquad \sigma_U=\sqrt{\frac{n_1n_2(n_1+n_2+1)}{12}},\qquad z=\frac{U-\mu_U}{\sigma_U}$$

For the example $\mu_U=18$ and $\sigma_U\approx6.245$, so $z\approx-2.56$ and the two-sided p-value is $0.0104$ (or $0.0131$ with a continuity correction), a little further from the exact $0.0087$. With ties, $\sigma_U$ also needs a tie correction.

Effect size: say how big, not just whether. Two rank-based measures read directly off $U$. The probability of superiority is $U_2/(n_1n_2)=34/36\approx0.944$: a random B wafer beats a random A wafer $94\%$ of the time, where $50\%$ means no difference. The rank-biserial correlation $(U_2-U_1)/(n_1n_2)\approx0.889$ rescales the same information to $-1$ to $+1$. If a shift in the original units is wanted, the Hodges-Lehmann estimate is the median of all pairwise differences $b-a$, which is $1.9$ here.

Reading the result.

  • What it tests: whether one group tends to produce larger values. It tests a difference in medians only if the two distributions have the same shape, differing by a shift.
  • Unequal spread: if the groups differ in spread as well as location, a significant result can reflect either. Look at the data, not just the p-value.
  • Ties: many ties, as with 1-to-5 ratings, reduce the number of distinct ranks and need a tie correction; software applies it automatically.
  • Independent groups only: for before-and-after values on the same wafers use the Wilcoxon signed-rank test, and for three or more groups use Kruskal-Wallis.
  • Power: on perfectly normal data it loses only about $5\%$ efficiency relative to the t-test, and on heavy-tailed data it can win by a wide margin.

Read the Mann-Whitney U as a head-to-head count: of all pairs formed by one measurement from each group, how often does each side win, and is that split more lopsided than shuffled ranks would produce?