The short answer
Interpret ranks first; interpret a location shift only when justified.
For every observation in group A, compare it with every observation in group B. The Mann–Whitney statistic counts how often A is larger, with half credit for ties. It therefore answers whether values in one population tend to rank above values in the other—not whether two sample medians happen to be different.
The canonical chorioamnion example
R's official wilcox.test documentation reproduces
Hollander and Wolfe's permeability constants for human
chorioamnion: ten measurements at term and five measurements at
12–26 weeks gestational age. The source's scientific alternative
is greater permeability at term.
| Group | All observations | Median |
|---|---|---|
| Term (n = 10) | 0.80, 0.83, 1.89, 1.04, 1.45, 1.38, 1.91, 1.64, 0.73, 1.46 | 1.415 |
| 12–26 weeks (n = 5) | 1.15, 0.88, 0.90, 0.74, 1.21 | 0.900 |
What U = 35 means
Ten term values crossed with five earlier values create 50 pairwise contests. The term value is larger in 35 of them, so U = 35 and the sample probability of superiority is 35/50 = 0.700. Equivalently, the rank-biserial correlation is 2 × 0.700 − 1 = 0.400.
Under exchangeability, all ways to allocate ten of the 15 pooled ranks to the term group form the exact null distribution. There are C(15,10) = 3,003 allocations. Doubling the tail at least as extreme as U = 35 gives the default two-sided result: exact P = 0.2544.
Why the median difference is not the tested effect
The sample medians differ by 1.415 − 0.900 = 0.515. But the Hodges–Lehmann estimate—the median of all 50 term-minus-earlier differences—is 0.305, with a 95% interval from −0.150 to 0.760 in Plotwright's normal-approximation interval. These are different estimands.
If the two population distributions have the same shape and spread and differ only by a location shift, that shift moves the median as well, and the rank result can support a median-shift interpretation. If shapes or spreads differ, a small P value can arise without a simple difference in population medians.
Do not choose it from a normality-test P value
- Start with the estimand: mean difference, quantile difference, stochastic ordering or a location shift are not interchangeable.
- Check independence from the design. Paired observations require a paired method; ranking does not erase pairing.
- Plot raw values and group distributions. “Nonparametric” does not mean assumption-free.
- Choose exact versus asymptotic inference deliberately. Ties, sample size and software conventions can change the reported P value.
A compact reporting template
“Permeability constants were compared between the term (n = 10) and 12–26-week (n = 5) groups using a two-sided exact Mann–Whitney test, U = 35, P = 0.2544. A term observation exceeded an earlier observation in 70.0% of cross-group pairs (rank-biserial r = 0.400). Under a location-shift interpretation, the Hodges–Lehmann shift was 0.305 (95% CI −0.150 to 0.760).”
What Plotwright checks
Plotwright submits all 15 values to the production Mann–Whitney engine. The published-example gate independently enumerates all 3,003 rank allocations and checks U, the exact two-sided P value, group medians, Hodges–Lehmann shift and interval, probability of superiority and rank-biserial correlation.
Those checks establish the defined calculation. They cannot establish independence, justify a location-shift model or choose a one-sided alternative for the researcher.
Sources and reproducibility
- R stats documentation: wilcox.test—the canonical values, two-sample rank-sum definition, directional example and distinction between a location shift and the difference of sample medians.
- NIST/SEMATECH: Mann–Whitney U—pooled ranks, rank sums, U and null-distribution logic.
- Hart (2001): not just a test of medians—why differences in distribution spread matter to the interpretation.
- Plotwright statistical validation—published expected values, tolerances and evidence limits.