Wilcoxon Rank-Sum Test Calculator

Quick answer

The Wilcoxon rank-sum test calculator compares two independent samples by ranking all observations together. It reports the rank-sum statistic W, its expected value and standard deviation, the equivalent Mann–Whitney U, the z-score and the exact or approximate p-value with a clear decision.

p-value
0.01
Rank-sum statistic W (sum of ranks of sample 1)
86.5
Expected W under H₀
64
Standard deviation of W (tie-corrected)
8.6255
z-score
2.5506
Decision
Reject H₀ at α = 0.05 – p = 0.0108 ≤ 0.05; the two distributions differ in location.
Method used
Normal approximation with tie correction and continuity correction
Rank sum of sample 2
33.5
Equivalent Mann–Whitney U₁
50.5
U (smaller of U₁, U₂)
5.5
Normal-approximation p-value
0.01
Mean rank, sample 1
10.813
Mean rank, sample 2
4.786
Median of sample 1
41
Median of sample 2
30
Hodges–Lehmann shift estimate
11
Effect size r = |z| ÷ √N
0.6586
Null distribution with rejection region
Ranks of the combined data
Value Sample Rank ─────────────────────── 25 Sample 2 1 28 Sample 2 2 29 Sample 1 3.5 29 Sample 2 3.5 30 Sample 2 5 31 Sample 2 6 33 Sample 2 7 34 Sample 1 8 36 Sample 2 9 38 Sample 1 10 41 Sample 1 11.5 41 Sample 1 11.5 45 Sample 1 13 47 Sample 1 14 52 Sample 1 15

Frank Wilcoxon introduced the rank-sum test in 1945 as a quick way to compare two treatments without assuming that the measurements are normally distributed. The idea is simple: put all observations from both groups in one list, rank them from smallest to largest and add up the ranks that belong to the first group. If both groups come from the same population, that rank sum W should be close to its expected value n₁(N + 1)/2; a much larger or smaller W suggests that one group tends to have higher values.

The test is mathematically equivalent to the Mann–Whitney U test published two years later – U₁ is just W minus the smallest possible rank sum, n₁(n₁ + 1)/2 – so both give the same p-value. Textbooks in medicine and biology often present the rank-sum form, while economics and psychology texts tend to use U.

Because it uses only the order of the data, the rank-sum test is robust to outliers and works with ordinal measurements such as pain scores. Ties receive average ranks and a correction to the variance. Do not confuse it with the Wilcoxon signed-rank test, which is for paired data.

How to use the Wilcoxon Rank-Sum Test Calculator

  1. Sample 1 (e.g. treatment)
  2. Sample 2 (e.g. control)
  3. Alternative hypothesis
  4. p-value method
  5. Continuity correction (normal approximation)
  6. Significance level (α)

Everything is calculated in your browser, so results appear instantly and nothing you type is sent to a server.

How it works

Enter both samples. The calculator ranks the combined data, sums the ranks of sample 1 to get W, and compares W with its null mean and standard deviation. Without ties and with modest sample sizes the exact null distribution is used; otherwise the normal approximation with tie and continuity corrections.

Worked example

Eight treated patients score 34, 41, 29, 45, 38, 52, 47 and 41; seven controls score 28, 31, 25, 36, 30, 33 and 29. In the combined ranking the two 29s share rank 3.5 and the two 41s share rank 11.5. The ranks of the treated group add up to W = 86.5.

Under H₀, E(W) = 8 × 16 ÷ 2 = 64 and the tie-corrected SD is 8.626. With the continuity correction z = (86.5 − 64 − 0.5) ÷ 8.626 = 2.55 and the two-tailed p-value is 0.011, so the treatment group scores significantly higher. The equivalent U₁ is 86.5 − 36 = 50.5, and the Hodges–Lehmann estimate of the shift is 11 points.

Assumptions

  • The two samples are independent of each other, and observations within each sample are independent.
  • The outcome is at least ordinal, so values can be ranked.
  • To interpret the result as a shift in medians, the two distributions should have a similar shape.

Formula

W = R₁ = sum of the ranks of sample 1 in the combined data · E(W) = n₁(N + 1)/2 · SD(W) = √(n₁n₂/12 × [(N + 1) − Σ(t³ − t)/(N(N − 1))]) · z = (W − E(W) ∓ 0.5) ÷ SD(W) · U₁ = W − n₁(n₁ + 1)/2

Worked example

Inputs — Sample 1 (e.g. treatment): 34, 41, 29, 45, 38, 52, 47, 41; Sample 2 (e.g. control): 28, 31, 25, 36, 30, 33, 29; Alternative hypothesis: The two samples differ (two-tailed); p-value method: Automatic (exact when possible); Continuity correction (normal approximation): Yes; Significance level (α): 0.05.
Results — p-value = 0.01; Rank-sum statistic W (sum of ranks of sample 1) = 86.5; Expected W under H₀ = 64; Standard deviation of W (tie-corrected) = 8.6255; z-score = 2.5506; Decision = Reject H₀ at α = 0.05 – p = 0.0108 ≤ 0.05; the two distributions differ in location..

Key terms

Rank sum (W)
The total of the ranks of one sample within the combined, sorted data.
Combined ranking
Ranking all observations from both samples together, ties sharing the average rank.
Tie correction
The reduction in the variance of W caused by groups of equal values.
Non-parametric test
A test that does not assume a specific distribution such as the normal.

Frequently asked questions

What is the difference between the Wilcoxon rank-sum and signed-rank tests?

The rank-sum test compares two independent groups; the signed-rank test compares paired measurements (or one sample against a median).

Is the Wilcoxon rank-sum test the same as Mann–Whitney?

Yes. They use different statistics (W and U) but U₁ = W − n₁(n₁ + 1)/2, so they always give the same p-value.

What is the expected rank sum?

n₁(N + 1)/2. With n₁ = 8 and N = 15 it is 64; the default data give W = 86.5, well above it.

Which sample should be sample 1?

Either. Swapping them changes W but not the two-tailed p-value. For a one-tailed test, make sure the direction matches your hypothesis.

How do ties affect the test?

Tied values share the average rank and the variance of W is reduced. The exact distribution assumes no ties, so with ties the normal approximation is used.

How do I report the result?

For example: "Scores were higher in the treatment group (median 41 vs 30), W = 86.5, z = 2.55, p = 0.011."

What does R's wilcox.test report?

R prints W as the Mann–Whitney U₁ rather than the rank sum. Use the "Equivalent Mann–Whitney U₁" line here to compare.

Sources

  1. Wikipedia – Mann–Whitney U test
  2. NIST/SEMATECH e-Handbook of Statistical Methods
  3. OpenStax – Introductory Statistics 2e

Cite this calculator

Speedy Calculator. (2026). Wilcoxon Rank-Sum Test Calculator. Speedy Calculator. https://speedycalculator.com/calculators/statistics/wilcoxon-rank-sum-test/