What Is the Mann-Whitney U Test?
The Mann-Whitney U Test is a nonparametric hypothesis test that determines whether two independent groups differ in their tendency to produce higher or lower values. It works by ranking all observations together, then checking whether the ranks are distributed evenly between the two groups.
H₀: P(X₁ > X₂) = 0.50 | H₁: P(X₁ > X₂) ≠ 0.50Henry Mann and Donald Ransom Whitney published the test in 1947 as a generalization of Frank Wilcoxon's 1945 rank-sum procedure. The two tests are mathematically equivalent — running a Wilcoxon rank-sum test and a Mann-Whitney U Test on the same data produces identical p-values. Many software packages use the names interchangeably, which explains why you may see "Wilcoxon rank-sum test" in R output when you call wilcox.test().
The test does not require the data to be normally distributed. Instead of computing means, it computes a statistic U that counts how many times an observation from group 1 exceeds an observation from group 2. When both groups are identically distributed (H₀ true), we expect U to be approximately n₁n₂ / 2. A very large or very small U signals that one group consistently outranks the other.
Assumptions of the Mann-Whitney U Test
The Mann-Whitney U Test has four assumptions. Meeting them ensures the p-value is valid and the result is interpretable.
Two Independent Groups
Observations in group 1 must be unrelated to observations in group 2. This rules out repeated measures or matched pairs — those designs call for the Wilcoxon signed-rank test instead. Within each group, individual observations must also be independent of one another.
Ordinal, Interval, or Ratio Scale Data
The test needs data that can be meaningfully ranked. Likert-scale ratings (1–5), reaction times, satisfaction scores, exam marks, and clinical measurements all qualify. Nominal categories with no natural order (e.g., blood type) do not — use a chi-square test instead.
Similarly Shaped Distributions (for Median Comparison)
Strictly speaking, the Mann-Whitney U Test compares stochastic dominance, not medians. If you want to conclude that one median is larger than the other, the two groups must have similarly shaped (though not necessarily equal variance) distributions. When shapes differ substantially, the test is still valid but the result should be stated as "group 1 values tend to be higher than group 2 values" rather than "group 1 median exceeds group 2 median."
Random Sampling
Observations in each group should represent a random sample from their respective populations. Non-random or convenience samples limit generalizability, just as they would for any statistical test.
The Mann-Whitney U Test does not assume normality. This is the primary reason to prefer it over the two-sample t-test when your data are skewed, contain outliers, or come from a small sample where normality cannot be confirmed with a Shapiro-Wilk or Kolmogorov-Smirnov test.
The Mann-Whitney U Test Formula
Two formulas calculate U — one for each group. You then take the smaller of the two as the test statistic.
n₁ = sample size of group 1
n₂ = sample size of group 2
W₁ = rank sum for group 1
W₂ = rank sum for group 2
U₁ + U₂ = n₁ × n₂
The rank sum W is computed by pooling both samples, ranking all N = n₁ + n₂ values from 1 to N (with ties receiving averaged ranks), then summing only the ranks belonging to each group. The U statistic directly counts the number of times a group 1 observation exceeds a group 2 observation — a cleaner interpretation than the formula might suggest.
Large-Sample Normal Approximation
When both sample sizes exceed about 20, the U statistic follows an approximately normal distribution. Convert U to a z-score using these formulas, then look up the p-value in the standard normal table.
μ_U = expected U under H₀
σ_U = standard deviation of U under H₀
When ties exist in the data, the variance formula for σ_U needs a correction: σ_U² = [n₁n₂ / N(N−1)] × [N³ − N − Σ(tⱼ³ − tⱼ)] / 12, where tⱼ is the number of observations in the jth tied group. Software applies this correction automatically. For manual calculations with few ties, the uncorrected formula gives a good approximation.
7-Step Calculation Procedure
The following steps apply to any Mann-Whitney U Test, whether done by hand or with software. The RANK Framework below captures the key phases as a memory aid.
State the Null and Alternative Hypotheses
H₀: The two populations have the same distribution — equivalently, P(X₁ > X₂) = 0.50. H₁ (two-tailed): The two distributions differ (P(X₁ > X₂) ≠ 0.50). For one-tailed tests: H₁: P(X₁ > X₂) > 0.50 or H₁: P(X₁ > X₂) < 0.50.
Set the Significance Level
Choose α before collecting or looking at the data. α = 0.05 is standard in most fields. Medical and safety research often uses α = 0.01. Exploratory research sometimes uses α = 0.10. See the full discussion at significance level.
Pool and Rank All Observations
Combine group 1 and group 2 values into one list. Sort from smallest to largest. Assign rank 1 to the smallest value, rank 2 to the next, and so on up to rank N = n₁ + n₂. When two values are tied, assign each the mean of the ranks they would have occupied. For example, if the 4th and 5th values are tied, each receives rank 4.5.
Compute the Rank Sums W₁ and W₂
Return each ranked value to its original group. Add up all the ranks belonging to group 1 — that is W₁. Add up all the ranks belonging to group 2 — that is W₂. A quick check: W₁ + W₂ must equal N(N + 1) / 2. If it does not, you made an arithmetic error in the ranking step.
Calculate U₁ and U₂
U₁ = n₁n₂ + n₁(n₁ + 1)/2 − W₁ | U₂ = n₁n₂ + n₂(n₂ + 1)/2 − W₂. Check: U₁ + U₂ = n₁ × n₂. Use U = min(U₁, U₂) as your test statistic for table lookup. Software usually reports both.
Find the p-value or Compare to Critical Value
For small samples (n₁ or n₂ ≤ 20): use the Mann-Whitney U critical value table — reject H₀ if U ≤ U_critical. For large samples: compute z = (U − n₁n₂/2) / σ_U and compare to the z-table.
Calculate Effect Size and State the Conclusion
Compute the rank-biserial correlation r = 1 − 2U / (n₁n₂). Report the decision in plain language and in APA format. A statistically significant result only tells you the groups differ; the effect size tells you how much they differ in practical terms.
Worked Examples
Both examples below show every calculation step explicitly. Example 1 uses a healthcare scenario with small samples where an exact U is compared to the critical value. Example 2 uses a larger educational dataset requiring the normal approximation.
Example 1 — Pain Scores: Treatment vs. Control
Problem: A clinical trial records post-operative pain scores (0–10 scale) for 8 patients receiving a new analgesic and 8 patients receiving a placebo. At α = 0.05, does the analgesic reduce pain scores?
Data:
| Treatment Group (T) | 2 | 3 | 4 | 4 | 5 | 6 | 7 | 8 |
|---|---|---|---|---|---|---|---|---|
| Control Group (C) | 4 | 5 | 6 | 7 | 7 | 8 | 9 | 10 |
Hypotheses: H₀: The pain score distributions are identical in both populations. H₁: Treatment group pain scores tend to be lower than control group scores (one-tailed). α = 0.05.
Pool and rank all 16 observations:
| Value | 2 | 3 | 4 | 4 | 4 | 5 | 5 | 6 | 6 | 7 | 7 | 7 | 8 | 8 | 9 | 10 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Group | T | T | T | T | C | T | C | T | C | T | C | C | T | C | C | C |
| Rank | 1 | 2 | 3.67 | 3.67 | 3.67 | 5.5 | 5.5 | 7.5 | 7.5 | 10.5 | 10.5 | 10.5 | 13.5 | 13.5 | 15 | 16 |
Note: The three 4s occupy ranks 3, 4, 5 → tied rank = (3+4+5)/3 = 4.0. (Revised: values 4 appear 3 times → mean rank = 4.0. Values 5 appear twice → mean rank = (5+6)/2 = 5.5, etc.) Blue cells = treatment group ranks.
Rank sums:
W₁ (Treatment) = 1 + 2 + 4 + 4 + 5.5 + 7.5 + 10.5 + 13.5 = 48
W₂ (Control) = 4 + 5.5 + 7.5 + 10.5 + 10.5 + 13.5 + 15 + 16 = 88
Check: 48 + 88 = 136 = 16 × 17 / 2 ✓
U statistics:
U₁ = 8 × 8 + 8(9)/2 − 48 = 64 + 36 − 48 = 52
U₂ = 8 × 8 + 8(9)/2 − 88 = 64 + 36 − 88 = 12
Check: 52 + 12 = 64 = 8 × 8 ✓ | U = min(52, 12) = 12
Critical value: For n₁ = n₂ = 8, α = 0.05 one-tailed, from the Mann-Whitney U Table: U_critical = 15. Since U = 12 ≤ 15, reject H₀.
Effect size (rank-biserial correlation):
r = 1 − 2U / (n₁n₂) = 1 − 2(12) / 64 = 1 − 0.375 = 0.625 (large effect)
✅ Conclusion: Pain scores were significantly lower in the analgesic group (Mdn = 4.5) compared to the control group (Mdn = 7), U(8, 8) = 12, p < .05, r = .63 (large effect). The analgesic reduces pain compared to placebo.
Example 2 — Student Exam Scores: Two Teaching Methods
Problem: An educator compares final exam scores for 15 students taught with Method A and 15 students taught with Method B. The data are right-skewed. At α = 0.05 (two-tailed), is there a difference in performance?
| Group | n | Median Score | Rank Sum (W) |
|---|---|---|---|
| Method A | 15 | 74 | W₁ = 196 |
| Method B | 15 | 82 | W₂ = 269 |
Check: 196 + 269 = 465 = 30 × 31 / 2 ✓
Hypotheses: H₀: Both teaching methods produce the same score distribution. H₁: The methods produce different score distributions (two-tailed). α = 0.05.
U statistics:
U₁ = 15 × 15 + 15(16)/2 − 196 = 225 + 120 − 196 = 149
U₂ = 15 × 15 + 15(16)/2 − 269 = 225 + 120 − 269 = 76
U = min(149, 76) = 76
Normal approximation:
μ_U = 15 × 15 / 2 = 112.5
σ_U = √[15 × 15 × (15 + 15 + 1) / 12] = √[225 × 31 / 12] = √581.25 = 24.11
z = (76 − 112.5) / 24.11 = −36.5 / 24.11 = −1.514
p-value: Two-tailed: p = 2 × P(Z < −1.514) = 2 × 0.065 = p ≈ 0.130
Decision: p = 0.130 > α = 0.05 → Fail to reject H₀
Effect size: r = 1 − 2(76) / 225 = 1 − 0.676 = 0.324 (small-to-medium effect)
✅ Conclusion: There is no statistically significant difference in exam scores between teaching methods, U(15, 15) = 76, p = .130, r = .32. Although Method B produced a higher median (82 vs. 74), the difference is not significant at α = 0.05 with this sample size.
Effect Size for the Mann-Whitney U Test
A statistically significant Mann-Whitney U Test tells you the groups differ — but not by how much. Always report an effect size. Two measures are appropriate: rank-biserial correlation (r) and Cliff's delta (δ).
Rank-Biserial Correlation (r)
|r| = 0.1 Small
|r| = 0.3 Medium
|r| = 0.5 Large
The rank-biserial correlation r ranges from −1 to +1. An r of +0.60 means that in 80% of all possible pairings, the group 1 observation exceeds the group 2 observation. An r of 0 means the groups perform identically by rank. The benchmarks (small = 0.1, medium = 0.3, large = 0.5) come from Cohen's (1988) guidelines adapted for nonparametric tests.
Cliff's Delta (δ)
Cliff's delta is a more direct measure of how often values in group 1 exceed values in group 2. It equals 2r (when using the rank-biserial formula), ranging from −1 (group 2 always higher) to +1 (group 1 always higher). Values near 0 mean nearly equal group performance. Many researchers prefer δ because it has a clearer probabilistic interpretation: δ = 0.40 means that a randomly chosen observation from group 1 exceeds a randomly chosen observation from group 2 by a margin of 40 percentage points more often than not.
| Cliff's Delta (|δ|) | Interpretation | r Equivalent | Practical Meaning |
|---|---|---|---|
| 0.00 – 0.11 | Negligible | < 0.10 | Groups effectively identical |
| 0.11 – 0.28 | Small | 0.10 – 0.30 | Small but detectable difference |
| 0.28 – 0.43 | Medium | 0.30 – 0.50 | Moderate practical difference |
| 0.43 – 1.00 | Large | ≥ 0.50 | Substantial real-world difference |
How to Report the Mann-Whitney U Test in APA Format
APA 7th edition (2020) requires you to report the U statistic, sample sizes, p-value, and an effect size. The median for each group should appear in the text or a table. Always report exact p-values (e.g., p = .023) rather than threshold statements (e.g., p < .05) unless the p-value is below .001.
- A Mann-Whitney U Test indicated that [dependent variable] was significantly [higher/lower] in the [group name] group (Mdn = [value]) than in the [group name] group (Mdn = [value]), U([n₁], [n₂]) = [U], p = [.xxx], r = [.xx].
- Note the parenthetical format: U(n₁, n₂) — not degrees of freedom, but sample sizes.
- Report medians (not means) because the test is rank-based.
- Include effect size r (rank-biserial correlation) or δ (Cliff's delta).
- For p < .001, write p < .001 (not p = .000).
APA Reporting Examples
APA Example — Significant Result
Clinical Trial: Pain Medication
A Mann-Whitney U Test indicated that pain scores were significantly lower in the analgesic condition (Mdn = 4.5) compared to the placebo condition (Mdn = 7.0), U(8, 8) = 12.0, p = .028, r = .63. This large effect suggests the analgesic has meaningful clinical benefits beyond placebo.
APA Example — Non-Significant Result
Education: Teaching Method Comparison
A Mann-Whitney U Test revealed no significant difference in exam scores between Method A (Mdn = 74) and Method B (Mdn = 82), U(15, 15) = 76.0, p = .130, r = .32. Despite the medium-sized difference, the result was not statistically significant at α = .05; a larger sample may be needed to detect this effect reliably.
Running the Mann-Whitney U Test in Software
Mann-Whitney U Test in R
R's built-in wilcox.test() function performs the Wilcoxon rank-sum test, which is identical to the Mann-Whitney U Test. R reports the W statistic (= U₁ in the formula above).
# Define the two groups group_a <- c(2, 3, 4, 4, 5, 6, 7, 8) group_b <- c(4, 5, 6, 7, 7, 8, 9, 10) # Two-tailed Mann-Whitney U Test with exact p-value result <- wilcox.test(group_a, group_b, alternative = "two.sided", exact = TRUE, conf.int = TRUE) print(result) # Compute rank-biserial correlation (effect size) # install.packages("rstatix") if needed library(rstatix) wilcox_effsize(data, score ~ group, ci = TRUE) # Output includes: W (= U₁), p-value, confidence interval
Mann-Whitney U Test in Python (SciPy)
Python's SciPy library provides scipy.stats.mannwhitneyu(), which directly computes the U statistic and p-value with both exact and asymptotic methods.
from scipy import stats import numpy as np group_a = [2, 3, 4, 4, 5, 6, 7, 8] group_b = [4, 5, 6, 7, 7, 8, 9, 10] # Mann-Whitney U Test (two-tailed, exact p-value) U_stat, p_value = stats.mannwhitneyu( group_a, group_b, alternative='two-sided', method='exact' # use 'asymptotic' for large n ) print(f"U = {U_stat}, p = {p_value:.4f}") # Effect size: rank-biserial correlation n1, n2 = len(group_a), len(group_b) r_effect = 1 - (2 * U_stat) / (n1 * n2) print(f"r = {r_effect:.3f}")
Mann-Whitney U Test in SPSS
/* SPSS: Nonparametric Tests → 2 Independent Samples */ NPAR TESTS /M-W= score BY group (1 2) /STATISTICS DESCRIPTIVES /MISSING ANALYSIS. /* Or via menus: */ /* Analyze → Nonparametric Tests → Legacy Dialogs → */ /* 2 Independent Samples → Mann-Whitney U */
Jamovi and JASP both provide Mann-Whitney U Test with effect sizes via point-and-click menus. GraphPad Prism labels it "Mann-Whitney test" under nonparametric comparisons. Stata uses ranksum varname, by(group). SAS uses PROC NPAR1WAY WILCOXON. All produce identical results to the manual formula.
Mann-Whitney U vs. Other Tests
Mann-Whitney U Test vs. Independent Samples t-Test
| Feature | Mann-Whitney U | Independent Samples t-Test |
|---|---|---|
| Data type | Ordinal, interval, ratio | Interval or ratio only |
| Normality required | No | Yes (or large n) |
| Compares | Rank distributions | Means (μ₁ vs. μ₂) |
| Sensitive to outliers | Low | High |
| Power (normal data) | ~95% of t-test | 100% (reference) |
| Small sample use | Yes (exact tables) | Requires normality verification |
| Tied values handling | Average tied ranks | Direct (no adjustment needed) |
When data are normally distributed, the t-test is slightly more powerful. The efficiency loss from using Mann-Whitney on normal data is only about 5% — a modest price for protection against non-normality violations. When data are skewed or contain outliers, Mann-Whitney is the appropriate choice. Check normality with a Shapiro-Wilk test for small samples (n < 50) or assess using a Q-Q plot.
Mann-Whitney U vs. Wilcoxon Signed-Rank Test
These two tests are frequently confused despite serving different purposes. The Mann-Whitney U Test applies to two independent groups — completely separate participants in each group. The Wilcoxon signed-rank test applies to two related groups — matched pairs or the same participants measured twice (before and after). Using the wrong test is a methodological error. If participants are matched or measurements are repeated, the Wilcoxon signed-rank test is correct; if they are separate and unrelated, use Mann-Whitney.
Mann-Whitney U vs. Kruskal-Wallis Test
The Kruskal-Wallis test is the nonparametric extension of one-way ANOVA — it compares three or more independent groups. The Mann-Whitney U Test handles exactly two groups. If a Kruskal-Wallis test is significant, Mann-Whitney U Tests are used as post-hoc pairwise comparisons (with Bonferroni correction applied to control the family-wise error rate).
| Test | Groups | Design | Parametric Equivalent |
|---|---|---|---|
| Mann-Whitney U | Exactly 2 | Independent | Independent samples t-test |
| Wilcoxon signed-rank | Exactly 2 | Paired / related | Paired samples t-test |
| Kruskal-Wallis | 3 or more | Independent | One-way ANOVA |
| Friedman | 3 or more | Repeated measures | Repeated-measures ANOVA |
When to Use the Mann-Whitney U Test: Decision Guide
Statistical Test Selection — Two-Group Comparison
For a comprehensive guide covering all hypothesis testing scenarios, visit the statistical test selector — an interactive decision tool that guides you from your data type and research design to the right test.
Real-World Applications of the Mann-Whitney U Test
The Mann-Whitney U Test appears across scientific disciplines precisely because ordinal data and non-normal distributions are the rule rather than the exception in real research.
Healthcare & Clinical Trials
Comparing pain scores, symptom severity ratings, or quality-of-life measures between treated and untreated patient groups. Common in Phase II drug trials where outcomes are Likert-rated.
Education Research
Assessing whether two teaching methods, curricula, or interventions produce different test score distributions when class sizes are small and normality cannot be verified.
Psychology
Comparing reaction times, Likert-scale attitude measures, or ordinal behavioral ratings between experimental and control groups in studies where outliers or ceiling effects distort means.
Market Research
Testing whether customer satisfaction scores differ between two products, customer service agents, or store locations when ratings follow a skewed distribution.
Manufacturing Quality
Comparing defect severity rankings or quality scores from two production lines, suppliers, or process settings when rankings rather than exact measurements are available.
Biology & Ecology
Comparing species abundance, growth measurements, or enzyme activity levels across two environmental conditions or treatment groups with small sample sizes.
Common Mistakes and Misconceptions
| Common Misconception | What's Wrong | Correction |
|---|---|---|
| "Mann-Whitney compares medians." | Only true when the distribution shapes are identical. In general it compares stochastic dominance (rank ordering). | Say "group 1 values tend to be higher than group 2 values" unless shapes are similar. |
| "A significant result proves the groups have different medians." | Groups with identical medians but different variances can also produce a significant U test. | Report medians but acknowledge the test reflects overall rank differences, not only central tendency. |
| "Mann-Whitney is always better than the t-test for small samples." | If data are actually normal, the t-test is slightly more powerful even for small n. | Check normality with a Shapiro-Wilk test or Q-Q plot first. Use Mann-Whitney when normality is violated. |
| "Mann-Whitney and Wilcoxon signed-rank are interchangeable." | Mann-Whitney is for two independent groups; Wilcoxon signed-rank is for paired or repeated-measures data. | Identify your study design first. Independent = Mann-Whitney. Paired = Wilcoxon signed-rank. |
| "No significant result means the groups are identical." | Failing to reject H₀ means insufficient evidence of a difference — not proof of equivalence. | Report the effect size. A small, non-significant r may indicate the study was underpowered, not that groups are the same. |
| "You don't need an effect size with Mann-Whitney." | Statistical significance depends on sample size. A tiny difference can become significant with a large n. | Always report r or Cliff's delta alongside U and p-value. |
Entity and Formula Glossary
Mann-Whitney U Test Calculator
Enter your two data groups below — separate values with commas. The calculator assigns ranks, computes U, runs both exact (small n) and asymptotic (large n) p-values, and generates the APA-formatted result.
Interactive Mann-Whitney U Test Calculator
Enter comma-separated values for each group. Works for both small samples (exact p-value) and large samples (normal approximation).