[SciPy-User] how to use stats.kruskal correctly?

josef.pktd at gmail.com josef.pktd at gmail.com
Fri Aug 14 10:26:11 EDT 2009


On Fri, Aug 14, 2009 at 8:03 AM, <josef.pktd at gmail.com> wrote:
> On Fri, Aug 14, 2009 at 7:35 AM, Chung, Tae-Hoon<hoontaechung at gmail.com> wrote:
>> Hi, All;
>>
>> What's the correct way to put something into the stats.kruskal function?
>> Any examples?
>> I tried one list with multiple lists as input or several lists
>> separately but none succeeded.
>> The reference contains only the following description, with no
>> explanation on input arguments:
>>
>> scipy.stats.kruskal(*args)
>>
>> The Kruskal-Wallis H-test is a non-parametric ANOVA for 2 or more
>> groups, requiring at least 5 subjects in each group. This function
>> calculates the Kruskal-Wallis H and associated p-value for 2 or more
>> independent samples.
>>
>> Returns: H-statistic (corrected for ties), associated p-value
>>
>> Thanks in advance,
>> Tae-Hoon Chung
>> _______________________________________________
>> SciPy-User mailing list
>> SciPy-User at scipy.org
>> http://mail.scipy.org/mailman/listinfo/scipy-user
>>
>
> I guess there is a check for input type, or conversion to array missing
>
>>>> stats.kruskal([1,2,3,4],[4,6,7,9])
> Traceback (most recent call last):
>  File "<pyshell#0>", line 1, in <module>
>    stats.kruskal([1,2,3,4],[4,6,7,9])
>  File "C:\Josef\scipytrunkcopy\scipy\stats\stats.py", line 2437, in kruskal
>    all.extend(args[i].tolist())
> AttributeError: 'list' object has no attribute 'tolist'
>
>>>> stats.kruskal(np.array([1,2,3,4]),np.array([4,6,7,9]))
> (4.7439759036144578, 0.029401048190339632)
>
> I will check this
>
> Josef
>

stats.kruskal needs a bit of a rewrite to use more of a numpy style
than the inherited python list style.

Until this is done the function assumes that the arguments are numpy
arrays, one for each data series or groups.
Currently all tests use numpy arrays.

For more examples on the usage of kruskal and related stats functions,
you can look at http://projects.scipy.org/scipy/ticket/901

Josef



More information about the SciPy-User mailing list