Course contentsShow
← Data Science
Lesson 393 of 2,14510. Hypothesis Tests for MeansFree lesson

Mann-Whitney U Test (Wilcoxon Rank-Sum)

Compare two independent samples by ranking all observations together and testing for location differences.

Mann-Whitney U Test (Wilcoxon Rank-Sum)

What you'll learn: How to compare two independent groups when parametric assumptions fail by ranking all observations together.

The Core Idea

When you want to compare two independent groups but the data violates normality assumptions or contains outliers, the Mann-Whitney U test (also called the Wilcoxon Rank-Sum test) offers a robust alternative to the two-sample t-test. Instead of comparing means directly, this test compares the distributions by asking: "Does one group tend to have systematically larger or smaller values than the other?"

The magic lies in ranking: you pool all observations from both groups, assign ranks from smallest to largest (ignoring which group they came from), then sum the ranks for each group. If the null hypothesis is true (no difference between groups), you'd expect the ranks to be evenly distributed. If one group consistently has higher ranks, that's evidence of a location shift.

How It Works

  1. Combine all observations from both groups
  2. Rank them from 1 (smallest) to n (largest), averaging tied ranks
  3. Sum the ranks for each group separately
  4. Calculate the U statistic based on these rank sums
  5. Compare to a sampling distribution (or use a normal approximation for larger samples) to find your p-value

Think of it like a tug-of-war: if Group A's observations pull toward higher ranks and Group B's pull toward lower ranks, the rope (rank distribution) moves in one direction—that's your evidence of a difference.

When to Use It

Use the Mann-Whitney U test when your samples are independent and you're uncertain about normality, have ordinal data, or want a test resistant to outliers.

Key Takeaway: The Mann-Whitney U test compares two independent groups by ranking all data together, making it a distribution-free alternative when parametric assumptions don't hold.