[SciPy-user] help with scipy.stats.mannwhitneyu

josef.pktd at gmail.com josef.pktd at gmail.com
Thu Feb 5 13:58:31 EST 2009


On Thu, Feb 5, 2009 at 1:53 PM,  <josef.pktd at gmail.com> wrote:
> On Thu, Feb 5, 2009 at 1:35 PM, Pierre GM <pgmdevlist at gmail.com> wrote:
>>
>> On Feb 5, 2009, at 1:31 PM, josef.pktd at gmail.com wrote:
>>
>>>
>>> Just calling this, according to docstring, requires sequence, correct
>>> usage is not clear:
>>>
>>>>>> stats.mstats.compare_medians_ms(rvs1,rvs2)
>>
>> OK, can you send me a test sample (ie, the rvs1& rvs2 you used that
>> fail, and what we should have had)? I'll try to fix that this
>> afternoon...
>>
>
> I generated rvs1 and rvs2 (without fixed seed)
>
> rvs1 = stats.norm.rvs(size = 100)
> rvs2 = 0.25*stats.norm.rvs(size = 100)
>
> I didn't look at stats.mstats.compare_medians_ms specifically, but it
> sounded like it should do something similar to the other tests I was
> trying out. So, I don't know what the expected answer should be, but I
> would expect a p-values similar to the other non-parametric tests for
> equality of location.
>
> the problem is in stats.mstats_basic.stde_median.
> Note: it is not exported  (I'm not sure how or why the imports work)
> and can be accessed only directly
>
>>>> stats.mstats.stde_median(rvs1,axis=0)
> Traceback (most recent call last):
>  File "<pyshell#143>", line 1, in <module>
>    stats.mstats.stde_median(rvs1,axis=0)
> AttributeError: 'module' object has no attribute 'stde_median'
>
> calling it directly returns this:
>
>>>> stats.mstats_basic.stde_median(rvs1,axis=0)
> Traceback (most recent call last):
>  File "<pyshell#142>", line 1, in <module>
>    stats.mstats_basic.stde_median(rvs1,axis=0)
>  File "C:\Programs\Python25\lib\site-packages\scipy\stats\mstats_basic.py",
> line 1514, in stde_median
>    return ma.apply_along_axis(_stdemed_1D, axis, data)
>  File "C:\Programs\Python25\lib\site-packages\numpy\ma\extras.py",
> line 185, in apply_along_axis
>    res = func1d(arr[tuple(i.tolist())], *args, **kwargs)
>  File "C:\Programs\Python25\lib\site-packages\scipy\stats\mstats_basic.py",
> line 1504, in _stdemed_1D
>    n = len(sorted)
> TypeError: object of type 'builtin_function_or_method' has no len()
>


doing : >>> np.source(stats.mstats_basic.stde_median)

shows it's a reference by wrong name: you assign the sorted data to
data, but then use "sorted" as a name

def _stdemed_1D(data):
        data = np.sort(data.compressed())
        n = len(sorted)

Josef



More information about the SciPy-User mailing list