Mann-Whitney U test calculator
Paste two lists of raw numbers from two independent groups, for example order value or time on page. The Mann-Whitney U test compares the ranks. You get the U statistic, exact and asymptotic p values, the tie-corrected normal approximation, and the rank-biserial effect size.
Short answer. Enter two independent samples of raw values. The calculator returns U1, U2, the midranks, the rank sums, the exact two-sided p value when there are no ties and each sample has at most 49 values, the asymptotic p value with and without the continuity correction, and the rank-biserial correlation. On the SciPy documentation example the page gives U1 = 17, U2 = 3 and the exact p value 0.1111111111111111, as the SciPy v1.18.0 manual prints. The table below shows each value.
Updated 2026-10-29
Calculator
The SciPy documentation example
The example data come from the SciPy manual for scipy.stats.mannwhitneyu: the ages at which nine randomly sampled young adults, five males and four females, were diagnosed with type II diabetes. SciPy takes the example from Rosie Shier, "Statistics: 2.3 The Mann-Whitney U Test", Mathematics Learning Support Centre, 2004. The table shows what this page calculates and what the SciPy v1.18.0 manual prints. The two asymptotic p values agree to 12 decimal places. SciPy manual, scipy.stats.mannwhitneyu.
| Quantity | This page | SciPy v1.18.0 manual |
|---|---|---|
| U1 (males) | 17 | 17.0 |
| U2 (females) | 3 | 3.0 |
| p, exact two-sided | 0.1111111111111111 | 0.1111111111111111 |
| p, asymptotic with continuity correction | 0.11134688653314062 | 0.11134688653314041 |
| p, asymptotic without continuity correction | 0.08641073297370006 | 0.0864107329737 |
With n = 5 and n = 4 there are 126 ways to split 9 ranks into groups of 5 and 4. The ranks of the males are 3, 5, 7, 8 and 9. Their rank sum is 3 + 5 + 7 + 8 + 9 = 32, so U1 = 32 − 5·6/2 = 17. The two-sided exact p value counts the splits with U ≤ 3 or U ≥ 17: 14 of 126, which is 1/9.
Ties and what SciPy does
- Equal values inside or between the samples get the average (mid) rank. The U statistic uses these mid ranks.
- With ties present, this page does not calculate the exact p value. This page computes the exact p value only when no value occurs more than once in the two samples together and each sample has at most 49 values. With ties, it shows only the tie-corrected asymptotic p values and says so.
- SciPy does not do the same thing in all modes. The SciPy manual says that
method="exact"makes "No correction" for ties, and thatmannwhitneyu"will not raise errors or warnings if there are ties". SciPymethod="auto""chooses 'exact' when the size of one of the samples is less than or equal to 8 and there are no ties; chooses 'asymptotic' otherwise." This page uses the tie-corrected variance n1·n2/12 · ((n + 1) − Σ(t³ − t)/(n(n − 1))), where t is the size of each group of equal values. - R-devel
wilcox.testuses a different rule: "an exact p-value is computed if the samples contain less than 50 finite values". With ties, R-devel does "exact inference" with "the conditional/permutation distribution". This page does not do that permutation calculation. With ties, it shows only the asymptotic p values. R manual, wilcox.test.
Effect size, the rank-biserial correlation
Alongside the p value the page reports the rank-biserial correlation r = 1 − 2U2/(n1·n2), which runs from −1 (every value in B is larger) to +1 (every value in A is larger). For the SciPy example r = 1 − 2·3/20 = 0.7. A p value measures the evidence against the null hypothesis that the two samples come from the same distribution; the rank-biserial tells you how strongly one group dominates. Fay and Proschan (2010) discuss the stochastic ordering and the Mann-Whitney functional views of the WMW test in "Wilcoxon-Mann-Whitney or t-test? On assumptions for hypothesis tests and multiple interpretations of decision rules", Statistics Surveys 4:1–39. Fay and Proschan 2010.
The calculator prints the midranks of each sample with every result, so you can verify the rank assignment by hand before you trust the p values.
Another view, the probability of a larger value
Divide U1 by n1·n2 and you get an estimate of p = P(A > B) + 0.5·P(A = B): the probability that a random value from sample A is larger than a random value from sample B, with half of the ties counted. The statsmodels manual defines this p for rank_compare_2indep, and its result object has methods for confidence intervals. For the SciPy example, U1/(n1·n2) = 17/20 = 0.85. statsmodels manual, rank_compare_2indep.
Mann-Whitney U or the two-sample t test?
The SciPy manual says: "When the means of samples from the populations are normally distributed, consider scipy.stats.ttest_ind." statsmodels states that the Mann-Whitney U test assumes equal variance or equal distribution under the null hypothesis. The chi-square test is not an alternative here: it works on category counts, not on raw values. For paired values of the same subjects, the SciPy manual names scipy.stats.wilcoxon.
Limits and accuracy
- The page calculates the exact p value with dynamic programming over all splits of the ranks. It shows the exact p value only when each sample has at most 49 values and no value occurs more than once. The two-sided exact p value is 2 × P(U ≥ max(U1, U2)), with a maximum of 1.
- The asymptotic p values use the tie-corrected standard deviation and the normal distribution, with and without the 0.5 continuity correction. With the correction, z = (max(U1, U2) − n1·n2/2 − 0.5)/σ, and the page uses z = 0 when this value is below 0. The SciPy manual gives the same form: z = (U − mn − d)/se.
- Values from −1,000,000,000 to 1,000,000,000 are accepted, with up to 10,000 values per sample. The exact p value is limited to 49 values per sample because the exact counting method stores (n1 + 1)(n1·n2 + 1) counts, so its memory grows quickly with the sample sizes. The calculation runs in your browser and makes no network request.
- The page rounds the rank sums, the U values, the rank-biserial r and U1/(n1·n2) to 12 significant digits. It shows the p values without rounding.
Disclaimers
- Results are statistical estimates and not medical, business or financial advice.
- The reference example is the published SciPy documentation example, and it names its source. The "Load a ties example" button loads 8 made-up values that only show how the page handles ties. The page has no data of this site.
By Michael Lip, builder and maintainer of ABWex, open source at github.com/theluckystrike/abwex.com. Profile.
ABWex is a free A/B test statistics calculator from Zovo Tools. The calculation runs in your browser in JavaScript. The page does not send the numbers that you enter to a server. Published 2026-10-29.