The Mann-Whitney U test is a widely used non-parametric statistical method for comparing differences between two independent groups. Unlike the independent samples t-test, it does not require the assumption of normality, making it a robust alternative when data are ordinal, skewed, or contain outliers. This test is often referred to as the Wilcoxon rank-sum test (the two names are mathematically equivalent). In this article, we provide a thorough guide to understanding, conducting, and interpreting the Mann-Whitney U test, including a step-by-step example, effect size measures, software implementations, and common pitfalls.

What Is the Mann-Whitney U Test?

The Mann-Whitney U test evaluates whether one group tends to have larger values than the other group by comparing the ranks of all observations. It tests the null hypothesis that the two independent samples come from the same population distribution against the alternative that one group is stochastically greater (or less) than the other. Because it is non-parametric, the test is appropriate when the assumptions of the parametric t-test are violated—especially normality and homogeneity of variance.

Developed by Henry Mann and Donald Whitney in 1947, and independently by Frank Wilcoxon, the test is one of the most popular non-parametric procedures. It is often taught alongside the Wilcoxon signed-rank test (for paired data) and the Kruskal-Wallis test (for more than two groups). For a historical context, see the original 1947 paper by Mann and Whitney.

When to Use the Mann-Whitney U Test

The test is ideal when you have two independent groups and your data meet the following criteria:

  • Independent samples: Observations in one group are not paired or related to those in the other group.
  • Ordinal or continuous data: The variable should be at least ordinal (e.g., Likert-scale responses, pain scores) or continuous (e.g., reaction times, test scores).
  • Non-normal distribution: If the data are severely skewed or have outliers, the Mann-Whitney U test is preferred over the t-test.
  • Similar distribution shape (optional but helpful for medians interpretation): To interpret the test as a comparison of medians, you need to assume that the distributions of the two groups have the same shape (aside from a possible shift).

Common applications include comparing treatment outcomes in clinical trials, analyzing survey responses between demographic groups, and evaluating performance metrics in user experience studies.

Assumptions of the Mann-Whitney U Test

To ensure valid results, the following assumptions should be satisfied:

  1. Independence: The samples are independent; no subject appears in both groups.
  2. Ordinal measurement: The data are at least ordinal so that ranking is meaningful.
  3. Random sampling: Ideally, the observations are randomly drawn from their respective populations.
  4. Identical shape under the null: The test is most powerful when the distributions are similar, but it remains valid for detecting any type of distributional difference (e.g., spread, shape). However, if you want to interpret the test strictly as a test of medians, you need to assume equal variances and shapes.

If the data are continuous and normally distributed, the t-test will be more powerful, but the Mann-Whitney U test still retains good efficiency (about 95% of the power of the t-test for normal data).

Conducting the Mann-Whitney U Test: Step-by-Step

Below we outline the procedure manually. In practice, you will use statistical software, but understanding the steps reinforces the logic.

Step 1: State the Hypotheses

Null hypothesis (H₀): The two populations are identical, i.e., there is no systematic tendency for one group to have larger values than the other. More formally, the probability that a randomly selected observation from Group A is greater than one from Group B equals 0.5.

Alternative hypothesis (H₁): The populations are not identical; specifically, one group tends to have larger values (two-sided or one-sided).

Step 2: Collect and Organize Data

Obtain two independent samples with sizes n₁ and n₂. The total number of observations is N = n₁ + n₂. Ensure your data are at least ordinal.

Step 3: Rank All Data Points Together

Combine the two samples and rank the observations from smallest to largest. If there are ties, assign the average rank to each tied value. For example, if the 4th and 5th observations are both 10, each gets rank 4.5.

Step 4: Sum the Ranks for Each Group

Let R₁ = sum of ranks of observations in Group 1, and R₂ = sum of ranks in Group 2. Note that R₁ + R₂ = N(N+1)/2.

Step 5: Compute the U Statistics

Calculate U₁ and U₂:

U₁ = n₁ n₂ + (n₁(n₁+1))/2 - R₁

U₂ = n₁ n₂ + (n₂(n₂+1))/2 - R₂

The test statistic is either min(U₁, U₂) or U₁ (depending on the software). The two U values sum to n₁ n₂.

Step 6: Determine the p-value

For small samples (typically n₁, n₂ ≤ 20), use the exact sampling distribution of U. For larger samples, the distribution of U approximates a normal distribution with mean = n₁ n₂ / 2 and standard deviation = sqrt(n₁ n₂ (N+1)/12). You can then compute a z-score and obtain a p-value from the standard normal distribution.

Step 7: Draw a Conclusion

If the p-value is less than your chosen significance level (e.g., α = 0.05), reject the null hypothesis and conclude that the two groups differ significantly.

Example Calculation

Suppose we have two groups of patients receiving different treatments. Their pain scores (on a scale 0-10) are:

  • Group A (Treatment 1): 4, 6, 8, 3, 5
  • Group B (Treatment 2): 9, 7, 10, 5, 6

Step 3: Rank all scores together. Sorted values: 3 (A), 4 (A), 5 (A), 5 (B), 6 (A), 6 (B), 7 (B), 8 (A), 9 (B), 10 (B). Ties: Two 5s get average rank (3+4)/2 = 3.5; two 6s get average rank (5+6)/2 = 5.5. Final ranks:

  • Group A: 1, 2, 3.5, 5.5, 7 → R₁ = 1+2+3.5+5.5+7 = 19
  • Group B: 3.5, 5.5, 8, 9, 10 → R₂ = 3.5+5.5+8+9+10 = 36

Check: R₁+R₂ = 19+36 = 55 = 10*11/2 = 55. Correct.

Step 5: Compute U. n₁=5, n₂=5. U₁ = 5*5 + (5*6)/2 - 19 = 25+15-19 = 21. U₂ = 25+15-36 = 4. The test statistic is U = min(21,4) = 4. (Some software uses U₁, but the conclusion is identical.)

Step 6: p-value. For n₁=5, n₂=5, the critical value at α=0.05 (two-tailed) is 2 for the smaller U. Since U=4 is greater than 2, we fail to reject H₀. There is no significant difference in pain scores between the two treatments at the 0.05 level.

In practice, always use software with correct handling of ties. For more examples, see the Laerd Statistics guide on SPSS.

Interpreting Results and Reporting

When reporting the Mann-Whitney U test, include the following:

  • The test statistic (U) and the sample sizes (n₁, n₂).
  • The p-value, with the exact significance level used.
  • An effect size estimate (see next section).
  • A statement about the direction of the difference, if significant.

Example: "A Mann-Whitney U test indicated that pain scores did not differ significantly between Treatment A (median = 5) and Treatment B (median = 7), U = 4, p = 0.075 (exact, two-tailed)."

Effect Size and Practical Significance

Beyond the p-value, quantifying the magnitude of the difference is essential. Two common effect sizes for the Mann-Whitney U test are:

Rank-Biserial Correlation (r)

Calculated as r = 1 - (2U)/(n₁ n₂) for the two-sided case, or equivalently r = (2U)/(n₁ n₂) - 1. The value ranges from -1 to 1, where 0 indicates no overlap. In our example, U=4, n₁ n₂=25, so r = 1 - (8/25) = 0.68, suggesting a moderate effect size in the direction of Group B having higher scores (though not significant).

Common Language Effect Size (CLES)

This estimates the probability that a randomly selected observation from Group A is greater than one from Group B. It equals U/(n₁ n₂). In our example, CLES = 4/25 = 0.16, meaning there is only a 16% chance that a value from Group A exceeds one from Group B. This is a more intuitive measure.

Using Statistical Software

All major statistical packages implement the Mann-Whitney U test. Below are examples in R and Python.

R

wilcox.test(x, y, alternative = "two.sided")

For the data above: wilcox.test(c(4,6,8,3,5), c(9,7,10,5,6)) returns U = 21 (the larger U) with p = 0.075. Alternatively, use exact = TRUE for exact p-value.

Python (SciPy)

scipy.stats.mannwhitneyu(x, y, alternative='two-sided') returns U = 21 and p = 0.075. Note that Python defaults to the larger of the two U values.

SPSS

Go to Analyze > Nonparametric Tests > Legacy Dialogs > 2 Independent Samples. Place the variable and grouping variable, select Mann-Whitney U, and run.

For more detail, see the SciPy documentation and the R documentation for wilcox.test.

Alternatives to the Mann-Whitney U Test

  • Independent samples t-test: Use when data are normally distributed and variances are equal. More powerful but less robust.
  • Welch's t-test: Does not assume equal variances, still requires normality. Often used instead of the pooled t-test.
  • Kruskal-Wallis test: Non-parametric test for three or more independent groups—the extension of Mann-Whitney.
  • Brunner-Munzel test: A more robust non-parametric test that does not assume equal distributions, even under the null hypothesis. Recommended when distributions differ in shape.

Also consider transformations before applying parametric tests, or using permutation tests for complete distribution-free inference.

Common Pitfalls and Misconceptions

Despite its simplicity, several mistakes occur frequently:

  • Assuming it tests medians without checking distribution shape: If the two groups have different variances or shapes, the Mann-Whitney U test may reject the null even when medians are equal, because it is sensitive to differences in distribution overall.
  • Using it for paired data: For dependent samples, use the Wilcoxon signed-rank test instead.
  • Ignoring ties: Ties reduce the variance and can inflate the test statistic if not handled correctly. Always use software that adjusts for ties.
  • Reporting only the p-value: Always include an effect size and confidence interval for the magnitude of difference.
  • Using a one-tailed test without strong prior justification: Two-tailed tests are standard; one-tailed tests require a clear directional hypothesis.

Conclusion

The Mann-Whitney U test is a fundamental tool for non-parametric analysis of two independent groups. By focusing on ranks, it avoids the restrictive assumptions of normality and is robust to outliers. This article has covered the test’s rationale, assumptions, step-by-step manual computation, interpretation with effect sizes, and software implementations. Whether you are working with clinical trial data, survey responses, or behavioral measurements, the Mann-Whitney U test provides a reliable method to detect group differences. Always remember to complement the test with appropriate effect size measures and to verify the assumptions that underpin your conclusions. For further reading, consult standard textbooks on non-parametric statistics or the Wikipedia article for a concise overview.