[SciPy-dev] Stats t-test broken on 1D input
Zachary Pincus
zpincus at stanford.edu
Thu Mar 2 13:50:01 CST 2006
Hi folks,
Sorry to re-post, but nobody in scipy-user seemed too concerned that
the most basic form of the most basic statistical test -- the T-test
on 1D input -- is broken in scipy 0.4.6.
In [1]: import scipy.stats
In [2]: scipy.version.version
Out[2]: '0.4.6'
In [3]: scipy.stats.ttest_ind([1,2,3],[1,2,3])
TypeError: len() of unsized object
In [4]: scipy.stats.ttest_rel([1,2,3],[1,2,3])
TypeError: len() of unsized object
The problem is at lines 1463 and 1512 of stats.py, where len() is
applied to a scalar result. This can be fixed by chainging the blocks
that look like:
if type(t) == ArrayType:
probs = reshape(probs,t.shape)
if len(probs) == 1:
probs = probs[0]
to look like:
if type(t) == ArrayType:
probs = reshape(probs,t.shape)
if len(probs) == 1:
probs = probs[0]
That is, probs is guaranteed to be a scalar ( I think) if t is not an
array. I assume that in a previous version of scipy this was not the
case, but now it is.
Zach Pincus
Program in Biomedical Informatics and Department of Biochemistry
Stanford University School of Medicine
More information about the Scipy-dev
mailing list