Mann–Whitney U test calculator
Compare two independent groups without assuming a normal distribution, with exact p-values for small samples.
A clear answer. Here’s how.
All values are ranked together, tied values sharing their average rank. U for group A = (rank sum of A) − n₁(n₁ + 1) ÷ 2, and U for B = n₁n₂ − U for A. Without ties and with 80 values or fewer the p-value comes from the exact null distribution, found by counting every way of choosing which ranks belong to A. Otherwise z = (U − n₁n₂ ÷ 2 ∓ 0.5) ÷ σ with σ² = n₁n₂ ÷ 12 × ((N + 1) − Σ(t³ − t) ÷ (N(N − 1))), where t are the tie group sizes, and the 0.5 is a continuity correction, as in R’s wilcox.test. The probability of superiority is U ÷ (n₁n₂), and the rank-biserial correlation is 2U ÷ (n₁n₂) − 1.
How this is checked
4 reference checks passed These 4 cases were run when this page was built, on 20 October 2026, and all reproduce within the stated tolerance. The same cases are part of the automated tests that run on every change to Toolmoz. Engine version 1.
See the checks and where each expected answer comes from
Case 1
- Inputs
- Group A values 0.80 0.83 1.89 1.04 1.45 1.38 1.91 1.64 0.73 1.46Group B values 1.15 0.88 0.90 0.74 1.21Alternative greater
- Expected, and what Toolmoz gave
- U for group A expected 35, Toolmoz 35U for group B expected 15, Toolmoz 15P-value (one-sided, A tends larger) expected 0.1272061, Toolmoz 0.1272061272061272
- Where the expected answer comes from
- R documentation example for wilcox.test: W = 35, p = 0.1272; p computed separately by listing all 3,003 ways to choose which 10 of the 15 values form group A
- Allowed difference
- ±0.000001 absolute
Case 2
- Inputs
- Group A values 0.80 0.83 1.89 1.04 1.45 1.38 1.91 1.64 0.73 1.46Group B values 1.15 0.88 0.90 0.74 1.21Alternative two
- Expected, and what Toolmoz gave
- P-value (two-sided) expected 0.2544123, Toolmoz 0.2544122544122544
- Where the expected answer comes from
- Twice the smaller one-sided tail of the same 3,003 arrangements: 2 × 0.1272061
- Allowed difference
- ±0.000001 absolute
Case 3
- Inputs
- Group A values 1 2 3Group B values 4 5 6Alternative two
- Expected, and what Toolmoz gave
- U for group A expected 0, Toolmoz 0P-value (two-sided) expected 0.1, Toolmoz 0.1Probability that A is larger than B (ties count half) expected 0, Toolmoz 0
- Where the expected answer comes from
- Only 1 of the C(6,3) = 20 arrangements puts the three smallest values in A, so P(U ≤ 0) = 1/20 and the two-sided p = 2/20 = 0.1
- Allowed difference
- ±1e-12 absolute
Case 4
- Inputs
- Group A values 1 2 2 3Group B values 2 3 4 5Alternative two
- Expected, and what Toolmoz gave
- U for group A expected 2.5, Toolmoz 2.5z score expected -1.4883514, Toolmoz -1.4883513944689681P-value (two-sided) expected 0.1366582, Toolmoz 0.13665824773814694
- Where the expected answer comes from
- Ties get average ranks: R1 = 1 + 3 + 3 + 5.5 = 12.5, U = 2.5, tie term 24 + 6 = 30, σ = √(16/12 × (9 − 30/56)) = 3.35942, z = (2.5 − 8 + 0.5) ÷ σ = −1.48835, p = 2 × Φ(z) = 0.13666
- Allowed difference
- ±0.000001 absolute
What this shows: the engine reproduces independently worked values for these cases. It does not prove every possible input is right. To test an answer you were given, see how to check a number; to see what is and is not checked across Toolmoz, see the accuracy ledger.
See a worked example
Worked example
A fixed demonstration, separate from the values you enter above.
- Group A values
- 0.80 0.83 1.89 1.04 1.45 1.38 1.91 1.64 0.73 1.46
- Group B values
- 1.15 0.88 0.90 0.74 1.21
- Alternative
- The groups differ (two-sided)
- P-value method
- Exact when there are no ties and 80 values or fewer; otherwise normal approximation
Example result
- Group A size
- 10
- Group B size
- 5
- U for group A
- 35
- U for group B
- 15
- Rank sum of group A
- 90
- Median of group A
- 1.415
- Median of group B
- 0.9
- P-value (two-sided)
- 0.254412
- Method
- Exact (no ties)
- Probability that A is larger than B (ties count half)
- 0.7000
- Rank-biserial correlation
- 0.4000
The Mann–Whitney (Wilcoxon rank-sum) test asks whether values in one group tend to be larger than in the other; it is not a test of medians unless the two distributions have the same shape. Samples are assumed independent.