standarddeviationcalculator.net

Updated Free · runs in your browser

Statistics

Mann–Whitney U test calculator

Compare two independent groups without assuming normal data. Paste the two samples; the calculator ranks them together, computes U for each group and gives the exact or approximate p-value, with every rank shown.

Mann–Whitney U 15
U₁ (for sample 1)35
U₂ (for sample 2)15
p-value0.2544
MethodExact
DecisionDo not reject H₀ at α = 0.05
z (continuity-corrected)1.164
Effect size r = |z|/√N0.316
P(sample 1 > sample 2), U₁/(n₁n₂)0.7
Rank sums R₁, R₂90, 30
n₁, n₂10, 5
00.020.0404812162024283236404448observed U₁ = 35U₁

Bars: P(U₁ = k) if H₀ is true. Solid bars: the rejection region at α = 0.05 (two-sided). The observed U₁ falls outside it, so H₀ is not rejected.

ValueGroupRank
0.73At term1
0.7412–26 weeks2
0.8At term3
0.83At term4
0.8812–26 weeks5
0.912–26 weeks6
1.04At term7
1.1512–26 weeks8
1.2112–26 weeks9
1.38At term10
1.45At term11
1.46At term12
1.64At term13
1.89At term14
1.91At term15
Show the working, step by step
  1. Rank all 15 values together, smallest = 1. Tied values share the average of the ranks they occupy.

  2. Add up the ranks in each group.

    R₁ = 90 (At term, n₁ = 10), R₂ = 30 (12–26 weeks, n₂ = 5) check: R₁ + R₂ = N(N + 1)/2 = 120

  3. Convert rank sums to U.

    U₁ = R₁ − n₁(n₁ + 1)/2 = 90 − 55 = 35 U₂ = n₁n₂ − U₁ = 50 − 35 = 15 U = min(U₁, U₂) = 15

  4. Mean and standard deviation of U under H₀.

    μ_U = n₁n₂/2 = 25 σ_U = √(n₁n₂/12 × ((N + 1) − Σ(t³ − t)/(N(N − 1)))) = 8.165

  5. Standardise U₁ (moving it 0.5 towards the mean).

    z = (U₁ − μ_U ∓ 0.5) ÷ σ_U = 1.1635

  6. p-value (two-sided), from the exact distribution of U (no ties, both n ≤ 20).

    exact p = 0.2544 (normal approximation: 0.2446)

U₁ counts, over all n₁n₂ pairs, how often a value from sample 1 beats one from sample 2 (ties count ½). Some books report U = min(U₁, U₂) and compare it with a lower critical value; the p-value is the same.

The formulas

U₁ = R₁ − n₁(n₁ + 1)/2, U₂ = n₁n₂ − U₁ μ_U = n₁n₂/2 σ_U = √[ n₁n₂/12 × ( (N + 1) − Σ(t³ − t) / (N(N − 1)) ) ] z = (U₁ − μ_U ∓ 0.5) ÷ σ_U

R₁ is the sum of the ranks of sample 1 in the combined data, N = n₁ + n₂, and t is the size of each group of tied values. U₁ also has a direct meaning: over all n₁n₂ pairs of one value from each group, it counts how many times the sample 1 value is larger, with ties counting ½.

Worked example

The default data are permeability measurements of the membrane around a fetus: 10 at full term and 5 taken between 12 and 26 weeks of pregnancy (the example in R's wilcox.test help page). Ranked together, the term values receive ranks 1, 3, 4, 7, 10, 11, 12, 13, 14 and 15.

  • Rank sums: R₁ = 90 for the term group and R₂ = 30 for the early group. Check: 90 + 30 = 15 × 16 ÷ 2 = 120.
  • U₁ = 90 − 10 × 11 ÷ 2 = 35, U₂ = 10 × 5 − 35 = 15, so U = 15.
  • There are no ties and both groups are small, so the p-value is exact. Of the C(15, 5) = 3,003 equally likely ways to assign the ranks, 382 give U₁ ≥ 35, a one-tailed probability of 0.1272. Doubling gives the two-tailed p = 0.2544.
  • The normal approximation would give z = 1.16 and p = 0.245, close to the exact value.

From a table, the two-tailed 5% critical value for n₁ = 10 and n₂ = 5 is 8. U = 15 is above it, and p = 0.25 is above 0.05, so the difference between the groups is not significant. The term values tend to be higher (P(term > early) = 35 ÷ 50 = 0.70), but with only five early measurements that could easily be chance.

Assumptions

  • The two samples are independent of each other. For paired data use the Wilcoxon signed-rank test.
  • Observations within each group are independent.
  • The variable is at least ordinal, so the values can be put in order.

Normality is not required. That is the reason to choose this test, not a weakness of it.

Common mistakes

  • Ranking each group separately. The ranks must come from the combined data.
  • Giving tied values different ranks. Ties share the average of the ranks they span.
  • Comparing U₁ with a lower-tail table value. Tables expect the smaller of U₁ and U₂.
  • Reporting the result as "the medians differ" when the two distributions have different shapes.
Mann–Whitney U test calculator: the worked example on this page, with its result and chart
Mann–Whitney U test calculator: the worked example above, at a glance.

Common questions

When should I use the Mann–Whitney U test instead of a t-test?

When you are comparing two independent groups and the data are ordinal (ratings, ranks) or clearly non-normal with small samples, for example strongly skewed times or incomes with outliers. The test uses only the order of the values, so a single extreme value cannot drag the result around. With roughly normal data the t-test is slightly more powerful.

Does the Mann–Whitney test compare medians?

Only if the two distributions have the same shape and differ just by a shift. In general it tests whether a value from one group tends to be larger than a value from the other, that is, whether P(X > Y) differs from ½. Two groups can have equal medians and still give a significant result if their shapes differ.

Which U do I report, U₁, U₂ or the smaller one?

Any of them, as long as you say which. U₁ + U₂ = n₁n₂, so one determines the other. Printed critical-value tables use the smaller U and reject when it is at or below the table value. R and most software report U₁ (called W in R's output). The p-value is the same either way.

When is the exact p-value used?

When there are no tied values and both groups have at most 20 observations. The calculator then counts, among all C(n₁ + n₂, n₁) equally likely ways to split the ranks, how many give a U at least as extreme. With ties or larger groups it uses the normal approximation with the tie and continuity corrections, as R's wilcox.test does.

What effect size goes with the Mann–Whitney test?

Two are common. r = |z| ÷ √N, read with the usual 0.1 / 0.3 / 0.5 benchmarks, and the common-language effect size U₁ ÷ (n₁n₂), the probability that a random value from group 1 beats one from group 2. In the example that probability is 35 ÷ 50 = 0.70.