[SciPy-User] Mann-Whitney U Test

Steve Ramage sjr at sjrx.net
Tue Dec 16 08:32:55 EST 2014


Hello,

I am wondering why the Mann-Whiney U Test always returns the smallu value in the source code, it seems like it should return the U statistic for x or y consistently. https://github.com/scipy/scipy/blob/v0.14.0/scipy/stats/stats.py#L3943 . 

I might be missing something, but it seems impossible to determine which distribution in the lower, Wikipedia gives an example of where the lower median is not correct, reproduced below:

#!/usr/bin/env python
import scipy.stats as stats
import scipy.stats.mstats as mstats

Hare =     [ 1 ,  2,  3,  4,  5,  6,  7,  8,  9, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]
Tortoise = [ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 30, 31, 32, 33, 34, 35, 36, 37, 38]

print "Hare Median: %d, Tortoise Median: %d, U1: %d, U2: %d"%(mstats.mquantiles(Hare,[0.5])[0],mstats.mquantiles(Tortoise,[0.5])[0], stats.mannwhitneyu(Hare, Tortoise)[0], stats.mannwhitneyu(Tortoise,Hare)[0])

Hare Median: 20, Tortoise Median: 19, U1: 100, U2: 100



More information about the SciPy-User mailing list