A Mann-Whitney U test calculator compares two independent samples without assuming that the data are normally distributed. Paste the values of each sample and it ranks them together, works out U for each sample, and gives a z score, a p-value and two effect sizes. It also serves as a Wilcoxon rank-sum test calculator.
How to use the Mann-Whitney U test calculator
- Paste the values of sample 1 and sample 2, separated by spaces, commas or new lines.
- Press Calculate.
- Read U, the p-value and the effect sizes. For small samples read the exact p-value.
What the test does
The Wikipedia article on the Mann–Whitney U test says that the test is also called the Wilcoxon rank-sum test and the Wilcoxon–Mann–Whitney test, and that it is not the Wilcoxon signed-rank test, which is for paired samples.[1] It ranks all the observations together: the smallest value gets rank 1 and the largest rank n1 + n2, and tied values get the midpoint of the ranks that they would have had.[1] The page gives the example of the values 3, 5, 5, 5, 5, 8, which receive ranks 1, 3.5, 3.5, 3.5, 3.5 and 6.[1]
The U statistics
With R1 and R2 as the sums of the ranks of the two samples, the page gives U1 = R1 − n1(n1 + 1) ÷ 2 and U2 = R2 − n2(n2 + 1) ÷ 2, and says that U is the smaller of the two.[1] It also notes that U1 + U2 = n1 × n2.[1] So each U counts how many times a value in one sample beats a value in the other, with ties counting one half.
The worked example from the page
The page compares six tortoises and six hares by their finishing order, T H H H H H T T T T T H. By direct counting, the tortoises win 6, 1, 1, 1, 1 and 1 comparisons, so their U is 11, and the hares win 5, 5, 5, 5, 5 and 0, so their U is 25; the sum is 36, which is 6 × 6.[1] By ranks, the tortoises have a rank sum of 12 + 6 + 5 + 4 + 3 + 2 = 32, so U = 32 − 21 = 11, and the hares have 46, so U = 46 − 21 = 25.[1] Enter 12 6 5 4 3 2 and 11 10 9 8 7 1 and the calculator gives U1 = 11 and U2 = 25. The page does not state a p-value for this example. Our calculator gives a normal approximation of z = −1.121 with p = 0.26 and an exact p-value of 0.31, which are our own calculations.
The normal approximation
Under the null hypothesis the page gives the mean of U as n1n2 ÷ 2 and the standard deviation, with no ties, as the square root of n1n2(n1 + n2 + 1) ÷ 12, and z = (U − mean) ÷ standard deviation.[1] For samples above about 20 it says that the normal approximation is fairly good.[1] When there are ties the variance is reduced: the page's form is n1n2 ÷ 12 × [(n + 1) − Σ(t³ − t) ÷ (n(n − 1))], where t is the size of each group of ties and n = n1 + n2.[1] The calculator uses this form whenever it finds ties. It does not use a continuity correction, because the page we read does not give one.
Exact p-values for small samples
For small samples the page says that the distribution is tabulated, and it mentions permutation methods as alternatives.[1] When there are no ties and each sample has at most 30 values, the calculator counts every possible arrangement of the ranks to find the exact distribution of U and doubles the lower tail for a two-sided p-value. This is our own working. For the six-and-six example, 924 arrangements are possible and the exact two-sided p-value is 0.31.
Effect sizes
The page gives the common language effect size as f = U1 ÷ (n1n2), the probability that a randomly chosen value from sample 1 is higher than one from sample 2, and the rank-biserial correlation as r = 2f − 1.[1] In the example, f = 11 ÷ 36 = 0.306 and r = −0.389, meaning sample 1 tended to have the lower values. A value of f of 0.5 and r of 0 means no difference in the sense of the test.
Assumptions
The page lists independent observations within and between groups, data that are at least ordinal, and identical distributions under the null hypothesis.[1] It warns that reading the test as a comparison of medians needs strict assumptions: if both the spread and the shape of the two distributions differ, the test can fail as a test of medians.[1] State your result as a difference in the ranks or in the probability that one value exceeds the other unless you are sure of equal shapes.
Reporting
Report the sample sizes, U, the p-value and the effect size, for example: Mann–Whitney U = 11, n1 = n2 = 6, exact two-sided p = 0.31. State whether you used the normal approximation or the exact test, and whether the data had ties.
Choosing between this test and a t-test
Use the Mann-Whitney test when the data are ordinal, when they are strongly skewed, or when there are outliers that you do not want to dominate the result. If the data are roughly normal with similar spread, the t-test is a little more powerful. The two tests answer slightly different questions, so choose the one that matches the hypothesis you set before collecting the data.
Common mistakes
- Using it for paired data. Use the Wilcoxon signed-rank test.
- Reading a non-significant result as no difference. Small samples have little power.
- Ignoring ties. Many ties change the standard deviation of U.
What next
Use this often? Add Mann-Whitney to your Home screen.
Frequently asked questions
What is a Mann-Whitney U test calculator?
A tool that compares two independent samples by ranking all the values together and testing whether one sample tends to have higher values than the other.
Is the Wilcoxon rank-sum test the same as the Mann-Whitney U test?
Yes. They are two names for the same test. The Wilcoxon signed-rank test is a different test for paired data.
How is U calculated?
U1 = R1 − n1(n1 + 1) ÷ 2, where R1 is the rank sum of sample 1, and U is the smaller of U1 and U2. U1 + U2 = n1 × n2.
When is the normal approximation good?
The page says that it is fairly good for sample sizes above about 20. For small samples, use an exact p-value.
How are ties handled?
Tied values get the average of their ranks, and the standard deviation of U is reduced by a correction for the ties.
Sources
Was this tool helpful?
What went wrong?
We only receive the reason you pick, never what you typed into the tool.
Thanks for your feedback.