Wilcoxon Rank Sum Test Calculator

Wilcoxon Rank-Sum Calculator

Rank two independent samples together and test whether one tends to sit higher, with every value's rank shown, the rank sum W, its expected value and the p-value.

W = sum of sample 1's ranks · E(W) = n₁(N + 1) ÷ 2

Enter both samples to rank them

What is the Wilcoxon Rank-Sum Test?

The Wilcoxon rank-sum test pools two samples, ranks every value from smallest to largest, and checks whether one sample's ranks add up to more than chance would allow.

If the samples come from the same population, their ranks should be shuffled together and each sample's rank sum should be near its fair share. A sample that grabs most of the high ranks has a rank sum well above that share.

Frank Wilcoxon published it in 1945; Mann and Whitney's U test, two years later, is the same test in a different form. Seeing the ranks laid out, as this page does, makes it easy to check the working by hand.

Wilcoxon Rank-Sum Formula

As introduced by Wilcoxon (1945); see also Hollander, Wolfe and Chicken. See Sources.

1. Rank the pooled values

ranks 1 to N = n₁ + n₂, ties share their average rank

2. Sum one sample's ranks

W = Σ ranks of sample 1
E(W) = n₁(N + 1) ÷ 2 · Var(W) = n₁n₂(N + 1) ÷ 12

3. Compare with the null distribution

Exact for small samples without ties · z = (W − E(W)) ÷ √Var(W) otherwise

W and Mann–Whitney's U differ by a constant, U₁ = W − n₁(n₁ + 1)/2, so the p-values match exactly.

Worked Example: Plant Heights with Fertiliser

Given:
Heights in cm with fertiliser 30, 35, 28, 40, 33, 37 and without 25, 27, 31, 22, 26, 29.
Step 1:
Fertilised plants' ranks among all 12:
28 → 5, 30 → 7, 33 → 9, 35 → 10, 37 → 11, 40 → 12
Step 2:
Rank sum against its expected value:
W = 54 · E(W) = 6 × 13 ÷ 2 = 39
Step 3:
Exact p:
P(W ≥ 54) × 2 = 0.0152
Result:
W = 54, p = 0.015

The fertilised plants took the top four ranks and most of the rest. That's good evidence the fertiliser helps, without assuming heights are normally distributed.

Ranking the Plant Heights

All 12 heights in order. Fertilised plants are sample 1.

Ranks of the worked example
HeightGroupRank
22 cmControl1
25 cmControl2
26 cmControl3
27 cmControl4
28 cmFertiliser5
29 cmControl6
30 cmFertiliser7
31 cmControl8
33 cmFertiliser9
35 cmFertiliser10
37 cmFertiliser11
40 cmFertiliser12

Common Wilcoxon Rank-Sum Mistakes

  • Confusing it with the signed-rank test. Both are Wilcoxon tests. Rank-sum is for two independent samples; signed-rank is for paired data.
  • Ranking each sample separately. All values must be ranked together in one list.
  • Giving tied values different ranks. Ties share the average of the ranks they occupy, such as 4.5 and 4.5.
  • Comparing W across different sample sizes. W depends on the sizes. Compare it with its expected value, or use the p-value.

Wilcoxon Rank-Sum FAQs

Is this the same as Mann–Whitney?

Yes. W and U are linked by U₁ = W − n₁(n₁ + 1)/2, and both give the same p-value. The Mann–Whitney calculator shows U and the probability of superiority.

Which sample should be sample 1?

Either. Swapping them changes W but not the two-sided p-value.

What do the highlighted rows show?

Sample 1’s values, so you can see at a glance whether they bunch at the top or bottom of the ranking.

What does R’s wilcox.test report as W?

R reports U₁, the Mann–Whitney form, under the name W. It’s W from this page minus n₁(n₁ + 1)/2.

Can I use it for ratings on a 1–5 scale?

Yes, but expect many ties. The p-value then comes from the normal approximation with a tie correction.

Does it need equal sample sizes?

No, any sizes work.

What’s the smallest sample it can work with?

Technically 2 each, but with fewer than about 4 per group no result can reach significance at 5%.

Is it less powerful than a t-test?

Only slightly with normal data, about 95% as efficient. With skewed data or outliers it’s often more powerful.

Sources

Related Tools