Rank Sum Calculator

Wilcoxon rank-sum / Mann–Whitney U test with ties, z-score and exact or normal p-values.

  1. Enter valuesUse your own inputs or an example
  2. CalculateApply your selected settings
  3. View resultExplore the answer and explanation

Enter the 2 samples

Enter your values below to get started.

Examples:
Separate values with spaces, commas or new lines.
Alternative hypothesis
Reset restores the default values.

Tips for this calculator

Samples can have different sizes (n₁ ≠ n₂).

Tied values get the average of the ranks they occupy.

With 20 or fewer values per sample and no ties, the headline p-value is exact.

W reported by R's wilcox.test equals U₁ here; SPSS reports the smaller U.

A rank sum calculator runs the Wilcoxon rank-sum test, known as the Mann–Whitney U test, which compares 2 independent samples by ranking all values together and adding the ranks of each sample. Paste 2 samples to get the rank sums, U, the z-score with tie and continuity corrections, the two-sided or one-sided p-value, an exact p-value for small samples without ties, and the effect size.

What Is a Rank Sum Test?

A rank sum test is a nonparametric test that compares 2 independent samples by ranking all observations together and checking whether 1 sample's ranks are systematically higher. Frank Wilcoxon introduced the test in 1945, and Henry Mann and Donald Ransom Whitney published the equivalent U statistic in 1947.

H0: P(X1>X2)=12H1: P(X1>X2)≠12H_0:\ P(X_1 > X_2) = \tfrac{1}{2} \qquad H_1:\ P(X_1 > X_2) \ne \tfrac{1}{2}

The test uses ranks instead of raw values, so the test works for skewed data, outliers and ordinal scales such as 1-to-5 ratings, where a t-test needs approximately normal data.

InteractiveSlide 1 group: overlap changes the rank sums

How Does the Rank Sum Calculator Work?

The rank sum calculator pools both samples, ranks the values from smallest to largest, adds the ranks of each sample and converts the rank sum into U, z and a p-value. Tied values share the average of their ranks, and the variance of U is reduced for ties.

InteractiveRanking with ties: average ranks
  1. Pool and sort

    All n₁ + n₂ values are sorted together, keeping track of the sample each value came from.

  2. Rank with ties

    Ranks run 1 to N. Three values tied at positions 3, 4 and 5 all get rank 4.

  3. Rank sums and U

    R₁ = sum of sample 1's ranks; U₁ = R₁ − n₁(n₁ + 1)/2 and U₂ = n₁n₂ − U₁.

  4. z and p

    z compares U₁ with its mean n₁n₂/2; the exact distribution of U is used for small samples without ties.

Rank Sum Test Formula

The rank sum test formula converts the rank sum R₁ into U₁ = R₁ − n₁(n₁ + 1)/2, then standardizes U₁ with its mean and standard deviation. U₁ equals the number of pairs (x, y) in which the sample 1 value is larger, counting ties as ½.

U Statistic

U1=R1−n1(n1+1)2,U2=n1n2−U1U_1 = R_1 - \frac{n_1(n_1+1)}{2},\qquad U_2 = n_1 n_2 - U_1

Mean and Standard Deviation of U

μU=n1n22\mu_U = \frac{n_1 n_2}{2}
σU=n1n212[(N+1)−∑(t3−t)N(N−1)]\sigma_U = \sqrt{\frac{n_1 n_2}{12}\left[(N+1) - \frac{\sum (t^3 - t)}{N(N-1)}\right]}

t is the size of each tie group; without ties, σU = √(n₁n₂(N + 1)/12).

z-Score with Continuity Correction

z=U1−μU∓0.5σUz = \frac{U_1 - \mu_U \mp 0.5}{\sigma_U}

Check: Rank Sums Total

R1+R2=N(N+1)2R_1 + R_2 = \frac{N(N+1)}{2}
InteractiveU counts winning pairs: every x against every y

Rank Sum Test vs. Other Nonparametric Tests

The rank sum test is the choice for 2 independent groups; 3 related tests cover paired data, 3 or more groups and normal data. Picking the wrong test is the most common error with rank-based statistics.

InteractivePick a study design: which rank test fits?

Wilcoxon rank-sum (Mann–Whitney U)

2 independent groups, any continuous or ordinal data.

Wilcoxon signed-rank test

2 paired measurements on the same subjects, such as before and after.

Kruskal–Wallis H test

3 or more independent groups; reduces to the rank-sum test for 2 groups.

Two-sample t-test

Compares means of normal data. The rank-sum test keeps about 95.5% (3/π) of the t-test's efficiency on normal data.

How to Do a Rank Sum Test by Hand

To do a rank sum test by hand, rank all values together, add the ranks of 1 sample, convert the sum to U and compare U with a critical value or the normal distribution. Here are sample 1 = 68, 72, 75, 80, 85, 90 and sample 2 = 60, 62, 65, 70, 74.

  1. Sorted: 60, 62, 65, 68, 70, 72, 74, 75, 80, 85, 90 → ranks 1 to 11.
  2. Sample 1 ranks: 4, 6, 8, 9, 10, 11; R₁ = 48. Sample 2: R₂ = 18.
  3. U₁ = 48 − 6 × 7 / 2 = 27; U₂ = 30 − 27 = 3; U = 3.
  4. μ = 15, σ = √(30 × 12 / 12) = 5.4772; z = (27 − 15 − 0.5) / 5.4772 = 2.0996.
  5. Two-sided p ≈ 0.0358 (exact p = 0.0303), so the difference is significant at 5%.
InteractiveStep through 2 rank sum tests

    Exact p-Value vs. Normal Approximation

    Small samples without ties use the exact distribution of U, while larger samples or tied data use the normal approximation with a tie and continuity correction. The exact distribution counts how many of the C(N, n₁) ways to split the ranks give each value of U.

    For 1–5 against 6–10, U = 0 happens in 1 of 252 equally likely splits, so the exact two-sided p is 2/252 = 0.007937, while the normal approximation gives 0.01219. R's wilcox.test uses the exact p for fewer than 50 values per sample without ties.

    InteractiveExact distribution of U vs. the normal curve

    Common Mistakes with Rank Sum Tests

    • Using it on paired data: before/after measurements on the same people need the Wilcoxon signed-rank test.
    • Ranking each sample separately: the ranks come from the pooled data.
    • Giving tied values different ranks: ties get the average rank, for example 2.5 and 2.5.
    • Reading it as a test of medians only: the test compares whole distributions; it tests medians only when both shapes match.
    • Mixing up U and W: U₁ = R₁ − n₁(n₁ + 1)/2; software reports W, U₁ or min(U₁, U₂).
    InteractiveTrue or false: rank sum tests
    1. The Mann–Whitney U test and the Wilcoxon rank-sum test give the same p-value.

    2. The rank sum test needs both samples to be the same size.

    3. Values tied at positions 4 and 5 both get rank 4.5.

    4. U₁ + U₂ = n₁ × n₂.

    5. The rank sum test is the right test for before-and-after scores of the same patients.

    Score: 0 / 5

    How to Use the Rank Sum Calculator

    Paste sample 1 and sample 2, choose the alternative hypothesis and α, and press Calculate. The result shows U, z and p, both rank sums, the exact p-value when available, an effect size, every rank and a rank plot.

    InteractiveLoad a ready-made rank sum test

    Each button fills the calculator and runs it.

    1. Paste the samples

      1 sample per box, values separated by spaces, commas or new lines.

    2. Pick the alternative

      Two-sided for any difference; one-sided when the direction was fixed in advance.

    3. Choose α

      0.05 is standard; use 0.01 for stricter evidence.

    4. Read the decision

      p < α rejects H₀; the steps tab shows ranks, U, σ and z.

    Real-Life Applications of the Rank Sum Test

    The rank sum test compares 2 groups whenever the data are skewed, ordinal or contain outliers. There are 5 common applications:

    • Clinical trials: pain scores on a 0–10 scale for a drug group and a placebo group.
    • A/B testing: time on page or order values, which have long right tails.
    • Psychology: Likert-scale ratings (1 to 5) from 2 independent groups.
    • Ecology: species counts at polluted and clean sites.
    • Machine learning: the area under the ROC curve (AUC) equals U₁ ÷ (n₁n₂).
    InteractiveClinical trial: change the drug effect and watch p

    Rank Sum Test Examples

    7 two-sample comparisons with their rank sums, U and p-values (continuity correction on).

    Rank Sum Test Examples
    SamplesR₁, R₂U₁, U₂zp (normal / exact)Calculator
    12 15 17 20 24 26 30 vs. 9 11 13 14 16 1863, 2835, 71.92860.0538 / 0.0513
    68 72 75 80 85 90 vs. 60 62 65 70 7448, 1827, 32.09960.0358 / 0.0303
    1–5 vs. 6–1015, 400, 25−2.50670.0122 / 0.0079
    2 4 6 8 vs. 1 3 5 7 920, 2510, 1001 / 1
    3 5 5 8 vs. 5 7 8 9 (ties)13.5, 22.53.5, 12.5−1.19070.2338 / –
    Pain scores, 10 vs. 10 (ties)140, 7085, 152.64810.0081 / –
    Response times, 8 vs. 890, 4654, 102.25800.0240 / 0.0207

    Popular Rank Sum Problems

    Try each one, then reveal the answer or solve it in the calculator.

    1. Sample 1: 68, 72, 75, 80, 85, 90. Sample 2: 60, 62, 65, 70, 74. Find R₁, U and the exact two-sided p-value.

      Show answerR_1 = 48,\ U = 3,\ p = 0.0303
    2. Sample 1: 1, 2, 3, 4, 5. Sample 2: 6, 7, 8, 9, 10. Find U and the exact two-sided p-value.

      Show answerU = 0,\ p = 2/252 \approx 0.0079
    3. Sample 1: 3, 5, 5, 8. Sample 2: 5, 7, 8, 9. Rank with ties and find R₁ and U₁.

      Show answerR_1 = 13.5,\ U_1 = 3.5
    4. Test whether sample 1 (23, 27, 31, 35, 38, 41, 45) tends to be larger than sample 2 (19, 22, 24, 26, 29, 33, 36) at α = 0.05.

      Show answerU_1 = 38,\ p_{\text{exact}} = 0.0487 < 0.05
    5. Pain scores: placebo 6 7 5 8 6 7 9 5 6 8, drug 4 5 3 6 4 5 7 3 4 6. Find z and the two-sided p-value.

      Show answerz = 2.6481,\ p = 0.0081
    6. Response times (ms): 120 135 98 160 142 155 130 148 vs. 110 95 125 102 118 99 131 105. Find U and the exact p-value.

      Show answerU = 10,\ p = 0.0207

    Explore More Sum Calculators

    Discover 67 free sum calculators across different categories. Find the right calculator for your needs.

    Browse All 67 Calculators
    Questions and answers

    Frequently Asked Questions

    What is a rank sum calculator?

    A rank sum calculator is an online tool that runs the Wilcoxon rank-sum (Mann–Whitney U) test on 2 independent samples. It ranks all values together, adds the ranks of each sample, and returns U, z and the p-value.

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

    Yes, the Wilcoxon rank-sum test and the Mann–Whitney U test are the same test written with different statistics. U₁ = R₁ − n₁(n₁ + 1)/2, so both give the same p-value.

    How do you handle ties in a rank sum test?

    Give tied values the average of the ranks they occupy, then reduce the variance of U by Σ(t³ − t)/(N(N − 1)), where t is the size of each tie group. Three values tied at positions 2, 3 and 4 all get rank 3.

    When should you use the rank sum test instead of a t-test?

    Use the rank sum test for 2 independent groups when the data are skewed, ordinal or contain outliers, or when the samples are small and normality is doubtful. Use the t-test for approximately normal data.

    What does the U statistic mean?

    U₁ is the number of pairs in which a sample 1 value beats a sample 2 value, counting ties as ½. U₁ ÷ (n₁n₂) estimates the probability that a random value from sample 1 is larger than one from sample 2.

    Can the samples have different sizes?

    Yes, the samples can have different sizes. The formulas use n₁ and n₂ separately, for example 6 values against 5 values.

    Does the rank sum test compare medians?

    No, the rank sum test compares whole distributions, not medians alone. The test becomes a test of medians only when both groups have the same shape and spread.

    What is the continuity correction?

    The continuity correction moves U₁ 0.5 toward its mean before computing z, since U takes whole or half values while the normal curve is continuous. The correction makes the normal p-value closer to the exact p-value.

    How big must the samples be for the normal approximation?

    The normal approximation works well once each sample has about 10 or more values. For smaller samples without ties, use the exact p-value, which this calculator reports.

    Conclusion

    The rank sum test compares 2 independent samples through the ranks of their pooled values, and the rank sum calculator returns the rank sums, U, z, the exact or normal p-value and an effect size in 1 step. Use average ranks for ties, the exact p for small samples and the signed-rank test for paired data.

    Not sure the rank sum test fits your data? Answer the questions below.

    InteractiveIs the rank sum test right for your data?