Skip to content

Mann-Whitney U Test Calculator

Run a Mann–Whitney U test (Wilcoxon rank-sum) on two independent samples: ranks with ties, U, exact or normal p-value, effect size and Hodges–Lehmann shift.

Calculator Details

p-value:0.0022See results ↓

Values of the first group, separated by commas, spaces or new lines.

Values of the second group.

Two-sided: the groups differ. Greater: sample 1 tends to be larger. Less: sample 1 tends to be smaller

Your Results

p-value: 0.0022

p-value

0.0022

two-sided, exact · significant at 5%

U statistic

U₁ = 53

U₂ = 3; smaller U = 3

Rank sums

89 / 31

Wilcoxon W = R₁ = 89

Rank-biserial correlation

0.893

P(sample 1 > sample 2) = 0.946

Effect size r

0.747

z ÷ √N (about 0.1 small, 0.3 medium, 0.5 large)

Hodges–Lehmann shift

2.25

Medians 8.1 and 5.8

U = 53 (U₂ = 3), two-sided p = 0.0022 (exact): a significant difference at the 5% level. The rank-biserial correlation is 0.893.

Compare scenarios

Save these inputs as a scenario, change them, and compare the results side by side.

Loading, available in a moment

Detailed Breakdown

All values ranked together
ValueSampleRank
4.9Sample 21
5.2Sample 22
5.4Sample 23
5.8Sample 24
6.1Sample 25
6.2Sample 16
6.6Sample 27
6.9Sample 18
7Sample 29
7.1Sample 110
7.8Sample 111
8.4Sample 112
8.9Sample 113
9.5Sample 114
10.2Sample 115
Rank sum, sample 189
Rank sum, sample 231

Tied values get the average of the ranks they would occupy (midranks).

How This Calculator Works

How it's calculated

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

μ = n₁n₂/2, σ² = n₁n₂/12 × ((N + 1) − Σ(t³ − t)/(N(N − 1)))

z = (U − μ ∓ ½)/σ (continuity correction), r = z/√N

Your numbers: n₁ = 8, n₂ = 7. Sample 1's ranks add to R₁ = 89, so U₁ = 89 − n₁(n₁ + 1)/2 = 53 and U₂ = n₁n₂ − U₁ = 3. With no ties, the p-value comes from the exact distribution of U for these sample sizes: p = 0.0022 (two-sided).

Frequently Asked Questions

What does the Mann–Whitney U test test?

Whether values from one group tend to be larger than values from another, using only their ranks. The null hypothesis is that a value drawn from either group is equally likely to be the larger one. If the two distributions have the same shape, a significant result can be read as a difference in medians.

When should I use it instead of a t-test?

When the data are ordinal (ratings, ranks), clearly not normal, or have outliers, especially with small samples. The t-test compares means and assumes roughly normal data; the Mann–Whitney test needs no distribution assumption and is barely less powerful than the t-test even when the data are normal.

Is it the same as the Wilcoxon rank-sum test?

Yes. Wilcoxon’s W is the sum of sample 1’s ranks, and U₁ = W − n₁(n₁ + 1)/2, so the two give the same p-value. For the default data W = 89 and U₁ = 53. R’s wilcox.test prints this U₁ and calls it W. It is not the Wilcoxon signed-rank test, which is for paired data.

Which U do I report?

Both U₁ and U₂ = n₁n₂ − U₁ carry the same information. Printed tables of critical values use the smaller one; SciPy and R report U₁ for the first sample. The default example has U₁ = 53 and U₂ = 3, so the smaller U is 3.

Exact or normal approximation?

With small samples and no ties, the exact p-value counts every possible arrangement of ranks. The default example gives an exact p of 0.0022; the normal approximation with continuity correction gives 0.0046. For samples above about 20 each, or with ties, the normal approximation with the tie correction is standard.

How do I handle ties?

Tied values get the average of the ranks they would have taken (midranks), and the variance of U is reduced by the tie correction Σ(t³ − t)/(N(N − 1)). With many ties, the exact distribution above no longer applies; the calculator then uses the normal approximation.

What effect size should I report?

The rank-biserial correlation 2U₁/(n₁n₂) − 1 runs from −1 to 1, and U₁/(n₁n₂) is the probability that a random value from sample 1 beats one from sample 2 (0.946 for the default data). r = z/√N is also common. The Hodges–Lehmann estimate, the median of all pairwise differences, gives the size of the shift in the data’s own units.

Two independent samples: midranks for ties, U₁ and U₂, the exact null distribution of U (Mann & Whitney 1947) when there are no ties and the samples are small, otherwise the normal approximation with the tie correction and an optional continuity correction, matching SciPy's mannwhitneyu and R's wilcox.test. Effect sizes: r = z/√N, rank-biserial correlation and the Hodges–Lehmann shift (point estimate only). Not included: exact p-values with ties (permutation tests), confidence intervals for the shift, paired data (Wilcoxon signed-rank test), and more than two groups (Kruskal–Wallis).

Mann-Whitney U Test Calculator (Wilcoxon Rank-Sum Test)

By FindMySum · Last reviewed

The Mann–Whitney U test, also called the Wilcoxon rank-sum test, compares two independent groups without assuming that the data follow a normal distribution. Instead of the values themselves, it uses their ranks, which makes it robust to outliers and suitable for ordinal data such as survey ratings. This calculator ranks your two samples, computes the U statistic and the rank sums, and gives the p-value either exactly or from the normal approximation, along with three effect sizes and the Hodges–Lehmann estimate of the shift between the groups.

How the test works

Pool the two samples and sort all the values from smallest to largest. Give each value its rank: 1 for the smallest, N = n₁ + n₂ for the largest. When values tie, each gets the average of the ranks they span (midranks). Then add up the ranks of sample 1 to get R₁.

U₁ = R₁ − n₁(n₁ + 1)/2

U₁ counts, over every pair of one value from each sample, how many times the sample-1 value is larger (ties count one half). It runs from 0, when every sample-1 value is smaller than every sample-2 value, to n₁n₂, when every one is larger. U₂ = n₁n₂ − U₁ counts the opposite. If the groups come from the same distribution, U₁ should be near its expected value n₁n₂/2.

The p-value

For small samples without ties, the calculator uses the exact null distribution of U: the share of all equally likely arrangements of the ranks that give a U at least as extreme as yours. It is computed with the recursion Mann and Whitney published in 1947, and matches SciPy's mannwhitneyu with method="exact".

For larger samples, or when there are ties, U is close to normal with mean n₁n₂/2 and variance

σ² = n₁n₂/12 × ((N + 1) − Σ(t³ − t)/(N(N − 1)))

where t is the size of each group of tied values. The calculator applies a continuity correction of ½, as SciPy and R do by default, and you can switch it off. "Automatic" uses the exact method when there are no ties and both samples have 20 values or fewer.

Worked example

The default data are two small groups of measurements: sample 1 has 8 values (7.1, 8.4, 6.2, 9.5, 7.8, 8.9, 10.2, 6.9) and sample 2 has 7 (5.4, 6.1, 4.9, 7.0, 5.8, 6.6, 5.2).

  • Ranking all 15 values, sample 1's ranks add up to R₁ = 89 and sample 2's to 31.
  • U₁ = 89 − 8 × 9/2 = 53, and U₂ = 8 × 7 − 53 = 3. Only 3 of the 56 pairs have the sample-2 value larger.
  • There are no ties and both samples are small, so the exact two-sided p-value is 0.0022. The one-sided p for "sample 1 is larger" is 0.0011.
  • The normal approximation with continuity correction would give 0.0046: close, but less accurate for samples this small.
  • Rank-biserial correlation: 2 × 53/56 − 1 = 0.89, a very large effect. The probability that a random sample-1 value beats a random sample-2 value is 53/56 = 0.946.
  • Hodges–Lehmann shift: the median of the 56 differences is 2.25, so sample 1 is about 2.25 units higher.

Effect sizes

A p-value says whether a difference is likely to be real, not how large it is. The rank-biserial correlation (2U₁/(n₁n₂) − 1) is the difference between the proportion of pairs favouring sample 1 and the proportion favouring sample 2. The common-language effect size U₁/(n₁n₂) is the probability of superiority. r = z/√N converts the normal-approximation z into a correlation-like scale, where 0.1, 0.3 and 0.5 are often called small, medium and large. The Hodges–Lehmann estimate is the most practical: a shift in the original units.

When to use something else

Use a paired test (the Wilcoxon signed-rank test) when each value in one sample is matched with one in the other, such as before-and-after measurements on the same people. With three or more groups, the Kruskal–Wallis test extends the same idea. If your data are roughly normal, the t-test compares means directly and gives a confidence interval for the difference; the Mann–Whitney test is the safer choice when you can't rely on that assumption.

More questions

What sample size do I need for a Mann–Whitney U test?

The test works with very small samples, but it cannot reach significance if they are tiny: with 3 values in each group, the smallest possible two-sided exact p-value is 0.1. As a rule of thumb, aim for at least 5 to 10 per group, and plan larger samples with a power analysis if you expect a modest effect.

Do the two samples need the same size?

No. The test handles unequal group sizes directly; n₁ and n₂ enter the formulas separately. Very unequal sizes reduce power compared with the same total split evenly, but the p-value remains valid.

What are the assumptions of the Mann–Whitney test?

The observations are independent within and between the groups, and the variable is at least ordinal, so values can be ranked. To interpret a significant result as a difference in medians, the two distributions should have roughly the same shape; otherwise it tells you that one group tends to have larger values, which can come from a difference in spread.

How do I report the result?

Give the group medians, U, the sample sizes, the p-value and an effect size, for example: 'Scores were higher in group A (median 8.1) than in group B (median 5.8), U = 53, n₁ = 8, n₂ = 7, exact p = 0.002, rank-biserial r = 0.89.' Say whether the test was one- or two-sided and exact or approximate.

Why does my statistics package give a different p-value?

Packages differ in their defaults: exact versus normal approximation, whether the continuity correction is applied, and how ties are handled. SciPy's mannwhitneyu and R's wilcox.test both use the continuity correction by default. Set the same options in the advanced section to match them.

Sources

This article explains how the calculator works and is general information, not financial, tax, legal or medical advice. Rules change; check the sources above or a qualified professional before you act.

Spotted a wrong result or a bug? Report a problem

May we count your visits with Invoker Analytics? It keeps a random visitor number in your browser. Your calculator inputs are never sent. Privacy policy