Mann–Whitney U Test (also called the Wilcoxon rank-sum test)#
A nonparametric, rank-based test of whether one group’s values tend to exceed another’s.
Important
✨ AI-generated content. This page was written with the assistance of an AI language model and is provided as a learning aid. Despite careful review, it may still contain mistakes, omissions, or out-of-date information. Whether you are new to the topic, a team lead, or a senior practitioner, treat it as a starting point rather than an authoritative reference: read it critically and independently verify anything you act on (code, commands, figures, and factual claims) against official documentation and primary sources before relying on it.
What it is#
The Mann–Whitney U test (equivalently the Wilcoxon rank-sum test) is a non-parametric test for whether two independent groups come from the same distribution. Unlike the t-test it makes no normality assumption — it works on the ranks of the pooled data, so it is the natural choice for skewed or ordinal data.
Assumptions#
The two samples are independent.
The outcome is ordinal or continuous.
Strictly, it tests stochastic dominance (whether one group tends to be larger); only when the two distributions have the same shape does it become a test of medians.
The U statistic#
Pool both groups, rank everything, and sum the ranks of each group (\(R_1, R_2\)). Then
For large samples \(U\) is approximately normal, giving a z-based p-value.
Hypotheses#
H₀ — the two groups come from the same distribution.
H₁ — one group tends to produce larger (or smaller) values than the other.
Worked example#
Group A = {88, 92, 100, 75, 85}, Group B = {60, 70, 65, 80, 72}. Rank all ten values, sum the ranks, compute \(U\), and look up the p-value; \(p < 0.05\) means the groups differ significantly.
from scipy.stats import mannwhitneyu
U, p = mannwhitneyu(group_a, group_b, alternative="two-sided")
The link to ROC-AUC#
The U statistic is mathematically equivalent to AUROC:
i.e. the probability that a randomly chosen value from one group outranks a randomly chosen value from the other — exactly the definition of AUROC. Testing whether two score distributions differ is the same computation as measuring a classifier’s ranking power.
Pitfalls and edge cases#
Ties — many tied values need a tie correction (most libraries apply one).
The “median” shortcut — only valid under equal-shape distributions; otherwise report it as a test of stochastic dominance.
Paired data — for matched samples use the Wilcoxon signed-rank test instead; this test is for independent groups.
Theme: Model Evaluation & Uncertainty · All terminology
Hint
Mind map — connected ideas
Multiclass AUROC · One-vs-Rest (OvR) AUROC · Bootstrap Confidence Intervals (CIs) · Probability
Hint
More in Model Evaluation & Uncertainty
Average Absolute Error (AAE) · Baseline Heuristics · Bootstrap · Bootstrap Confidence Intervals (CIs) · Coverage · Cramér’s V · DeLong’s Test · KS Statistic (Kolmogorov–Smirnov Statistic) · Likelihood Ratio (LR) · MASE (Mean Absolute Scaled Error) · Mean Absolute Error (MAE) · Mean Absolute Percentage Error (MAPE) · Mean Squared Error (MSE) · Relative accuracy
See also
Source article Adapted (context, re-expressed) in our own words from: Mann–Whitney U Test (also called the Wilcoxon rank-sum test) (insightful-data-lab.com).