SciPy

scipy.stats.mannwhitneyu

scipy.stats.mannwhitneyu(x, y, use_continuity=True, alternative=None)[source]

Compute the Mann-Whitney rank test on samples x and y.

Parameters
x, yarray_like

Array of samples, should be one-dimensional.

use_continuitybool, optional

Whether a continuity correction (1/2.) should be taken into account. Default is True.

alternativeNone (deprecated), ‘less’, ‘two-sided’, or ‘greater’

Whether to get the p-value for the one-sided hypothesis (‘less’ or ‘greater’) or for the two-sided hypothesis (‘two-sided’). Defaults to None, which results in a p-value half the size of the ‘two-sided’ p-value and a different U statistic. The default behavior is not the same as using ‘less’ or ‘greater’: it only exists for backward compatibility and is deprecated.

Returns
statisticfloat

The Mann-Whitney U statistic, equal to min(U for x, U for y) if alternative is equal to None (deprecated; exists for backward compatibility), and U for y otherwise.

pvaluefloat

p-value assuming an asymptotic normal distribution. One-sided or two-sided, depending on the choice of alternative.

Notes

Use only when the number of observation in each sample is > 20 and you have 2 independent samples of ranks. Mann-Whitney U is significant if the u-obtained is LESS THAN or equal to the critical value of U.

This test corrects for ties and by default uses a continuity correction.

References

1

https://en.wikipedia.org/wiki/Mann-Whitney_U_test

2

H.B. Mann and D.R. Whitney, “On a Test of Whether one of Two Random Variables is Stochastically Larger than the Other,” The Annals of Mathematical Statistics, vol. 18, no. 1, pp. 50-60, 1947.

Previous topic

scipy.stats.epps_singleton_2samp

Next topic

scipy.stats.tiecorrect