Mann-Whitney U Test Calculator

Compare two samples without assuming a normal distribution, using ranks, the U statistic and a normal approximation.

Math and PercentUpdated 2026-10-224 min read
Mann-Whitney U Test Calculator
At least 5 numbers, separated by commas, for example 12, 15, 14, 13, 19.
At least 5 numbers, separated by commas, for example 8, 9, 11, 10, 6.
The usual choice is 0.05. The tool compares the p value with this number.
U statistic for sample 1
...
z score...
p value...
Rank biserial correlation...
Medians of the two samples...
Reading of the result...

What it does

Two groups of measurements arrive. The textbook advice says to run a t test, but the data is skewed, the sample is small, or one of the values is an outlier that stretches the standard deviation. The Mann Whitney U test is the standard answer to that situation. It asks whether one sample tends to hold larger values than the other, and it does so by looking only at the order of the data.

The procedure is short. Rank every observation from both samples together, giving tied values the average of the ranks they share. Add the ranks of the first sample to get the rank sum, and do the same for the second. From those sums comes the U statistic, which counts how many times a value in one sample falls below a value in the other.

The NIST handbook sets out the test in exactly that form, and calls the U test the nonparametric equivalent of the t test for means. Its null hypothesis is that the two populations have the same central tendency. For samples of more than about 20 values the handbook moves to the normal approximation, with the expected value of U at one half of the product of the two sample sizes, and the standard deviation coming from the same formula.

This page does the whole chain: the rank sums, the U statistic for each sample, the z score with a tie correction and a continuity correction, the p value for a two sided or a one sided test, the rank biserial effect size, and a plain sentence saying whether the result clears the significance level you chose.

The limits are worth knowing. The test is about location, not about spread, so two samples with the same medians but very different shapes can look different under it. It assumes the observations are independent, and with very small samples the exact tables are the right answer rather than the normal approximation used here.

How to use

  1. Paste the first sample into the first box and the second sample into the second box. Each one needs at least 5 numbers separated by commas.
  2. Choose the alternative hypothesis: two sided if you only care whether the samples differ, or one sided if you had a reason to expect a direction.
  3. Set the significance level, which is 0.05 unless your field uses another value.
  4. Read the U statistic and the z score. The z score is the number to compare with a table of normal values.
  5. Read the p value and the verdict, which tells you whether the result clears the significance level you set.
  6. Look at the rank biserial correlation to see the size of the shift, and at the medians for a number you can quote in plain words.

Formula

U = n1 x n2 + 0.5 x n1 x (n1 + 1) - T1, with T1 the sum of the ranks of sample 1, then z = (U - mean of U) over the standard deviation of U.
U
Test statistic counting how often a value in one sample falls below a value in the other.
T1
Sum of the ranks of the values in sample 1 after all values from both samples are ranked together.
n1, n2
Number of values in each sample.
mean of U
Expected value of U under the null hypothesis, which is n1 x n2 over 2.
standard deviation of U
Square root of n1 x n2 over 12 times N + 1, with a correction for tied values, where N = n1 + n2.

The two U values add up to n1 x n2, so only one of them needs to be worked out. The variance of U carries a correction for tied values, which subtracts the sum of t cubed minus t for each group of tied ranks. A continuity correction of half a standard deviation is applied before the z score is formed, which makes the test slightly conservative.

Worked example

Example: two samples of five values with no overlap

Defaults: sample 1 of 12, 15, 14, 13, 19 and sample 2 of 8, 9, 11, 10, 6, a two sided test and a significance level of 0.05.

  1. Rank the ten values together: 6 is 1, 8 is 2, 9 is 3, 10 is 4, 11 is 5, 12 is 6, 13 is 7, 14 is 8, 15 is 9 and 19 is 10.
  2. The ranks of sample 1 are 6, 9, 8, 7 and 10, which add up to 40. Sample 2 takes the rest, 15, and 40 + 15 = 55 is the total of the ranks from 1 to 10.
  3. U for sample 1 is 5 x 5 + 0.5 x 5 x 6 - 40 = 25, and U for sample 2 is 0. The expected value is 5 x 5 over 2 = 12.5.
  4. With no ties the standard deviation is the square root of 5 x 5 over 12 times 11, which is 4.7871.
  5. With the continuity correction z = (25 - 12.5 - 0.5) / 4.7871 = 2.5067.
  6. The two sided p value is 2 x (1 - the normal probability at 2.5067) = 0.0122, which is below 0.05.
  7. The tool shows U = 25, z = 2.5067, p = 0.0122, a rank biserial correlation of 1.0000, medians of 14 and 9, and a result that is significant at 0.05.

Reference table

What a z score means for the p value, on both the two sided and the one sided reading
Absolute zTwo sided pOne sided pUsual reading
1.6450.1000.050marginal evidence
1.9600.0500.025the usual 5 % cut
2.5760.0100.005strong evidence
3.2910.0010.0005very strong evidence

Limits

  • The test compares the location of the two samples, so it says little about the spread inside each group.
  • It assumes the observations are independent and that each sample is a fair draw from its population.
  • The normal approximation used here needs reasonably sized samples. With fewer than about 5 values in a group the exact tables are the right reference.
  • It does not correct for several comparisons. Running it many times and keeping the interesting results inflates the error rate.

Common mistakes

  • Running a t test and a rank test on the same data and reporting the more favourable one. Pick the test before you look at the result.
  • Forgetting to rank the values of both samples together. The ranks only mean something when every value from both samples shares one ranking.
  • Using the U statistic for the wrong sample when you report it. The two U values are not the same, and they add up to n1 x n2.
  • Treating a small p value as proof that the effect matters in practice. The effect size row is what says how big the shift is.
  • Ignoring ties. Repeated values are common in small samples, and the variance needs a tie correction or the p value comes out too small.

Try it yourself

Quick checks. Answers sit tucked under each question.

Two samples of 20 values each overlap heavily. What does the test say?

With sample 1 running from 3 to 22 and sample 2 from 2 to 21, the U statistic is 219.5 against an expected 200, z = 0.5144 and the p value is 0.6070, which is not significant at 0.05. The rank biserial correlation is only 0.0975, and the medians are 12.5 and 11.5.

What is the one sided p value for the default samples if you expected sample 1 to be higher?

0.0061, which is half of the two sided 0.0122. The z score of 2.5067 is the same, and with a one sided alternative only one tail of the normal distribution counts.

How do the medians and the effect size describe the default samples?

The medians are 14 for sample 1 and 9 for sample 2, and the rank biserial correlation is 1.0000. Every value of sample 1 sits above every value of sample 2, so the shift between the two groups is complete, which is what the correlation of 1 means.

Questions

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

When the data is strongly skewed, when the sample is small, or when outliers distort the mean and the standard deviation. The rank test only needs the order of the values, so it does not need the normality assumption the t test makes.

What does the U statistic mean?

It counts the comparisons between the two samples. A U of 25 out of a maximum of 25 means that every value in sample 1 sits above every value in sample 2, and a U near half the maximum means the samples are mixed together.

What is the rank biserial correlation?

A way of expressing the size of the difference between the two samples on a scale from minus one to plus one. It is built from the same U statistic, so it adds the magnitude of the shift to the test result.

Does the test need normal data?

No. That is the point of it. The NIST handbook describes it as the nonparametric equivalent of the t test, which means it makes no assumption about the shape of the distributions behind the samples.

What if there are tied values?

Each tied value receives the average of the ranks it shares, and the variance of U is corrected for the ties. The tool reports how many tied groups it found and applies that correction.

Is the test the same as the Wilcoxon rank sum test?

Yes, the two names point at the same calculation. The NIST handbook notes that although it is often called the Mann Whitney test, it was in fact developed by Wilcoxon, and the names are used interchangeably in the literature.

Sources

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.