[Scipy-tickets] [SciPy] #1527: stats.kruskal not working as advertised

SciPy Trac scipy-tickets@scipy....
Thu Sep 29 17:31:07 CDT 2011


#1527: stats.kruskal not working as advertised
-------------------------+--------------------------------------------------
 Reporter:  ckuster      |       Owner:  somebody   
     Type:  defect       |      Status:  new        
 Priority:  normal       |   Milestone:  Unscheduled
Component:  scipy.stats  |     Version:  0.9.0      
 Keywords:               |  
-------------------------+--------------------------------------------------
 The Kruskal-Wallis code (kruskal) does not seem to be working as
 advertised.

 According to the documentation, It takes two or more arrays as input (like
 the f_oneway function), but the function dies with an error if you pass
 arrays to it.

 Changing line 3552 in the current repository code seems to fix the
 problem.  (the .tolist() part should be removed)
 This code is also present in the current stable release.

 diff stats.py.new stats.py.current

 3552c3552

 <         all.extend(args[i])

 ---

        all.extend(args[i].tolist())

 After making this change, kruskal and f-oneway are interchangeable (as it
 seems they should be).

 ***Code

 # One-way ANOVA and Kruskal-Wallis

 s1 = [60.8, 67.0, 65.0, 68.6, 61.7]

 s2 = [68.7, 67.7, 75.0, 73.3, 71.8]

 s3 = [69.6, 77.1, 75.2, 71.5]

 s4 = [61.9, 64.2, 63.1, 66.7, 60.3]

 print stats.f_oneway(s1,s2,s3,s4)

 print stats.kruskal(s1,s2,s3,s4)

 Before Change

 ***Output

 (12.040403851546342, 0.00028301222846134437)

 Traceback (most recent call last):
  File "stat_test.py", line 31, in <module>
    print stats.kruskal(s1,s2,s3,s4)
  File "/Library/Python/2.6/site-
 packages/scipy-0.10.0.dev_20110710-py2.6-macosx-10.6-universal.egg/scipy/stats/stats.py",
 line 3538, in kruskal
    all.extend(args[i].tolist())
 AttributeError: 'list' object has no attribute 'tolist'


 After removing .tolist()

 ***Output

 (12.040403851546342, 0.00028301222846134437)

 (13.389473684210529, 0.0038657624047977669)

 As expected.

-- 
Ticket URL: <http://projects.scipy.org/scipy/ticket/1527>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.


More information about the Scipy-tickets mailing list