[SciPy-user] skew and kurtosis return different types

Jarrod Millman millman@berkeley....
Wed Oct 10 13:20:33 CDT 2007


Hey John,

I agree moments of a distribution should be of type float.  Currently,
it is for everything except skew and Pearson's kurtosis:
>>> scipy.stats.moment(a)
0.0
>>> scipy.stats.variation(a)
0.58315293025701254
>>> scipy.stats.skew(a)
array(0.0)
>>> scipy.stats.kurtosis(a)
-1.2002400240024003
>>> scipy.stats.kurtosis(a,fisher=False)
array(1.7997599759975997)

We could fix this by either having the functions subtract zero or make
a method call:
>>> scipy.stats.skew(a)
array(0.0)
>>> scipy.stats.skew(a) - 0
0.0
>>> scipy.stats.skew(a).tolist()
0.0
>>> scipy.stats.skew(a).item()
0.0

Does it make any difference if we do it one way or another?  Are there
any situations where returning an array with 1 element is importantly
different than returning a float?  If we want all the moments to
return values of the same type, my preference would be to use the
.item method.

-- 
Jarrod Millman
Computational Infrastructure for Research Labs
10 Giannini Hall, UC Berkeley
phone: 510.643.4014
http://cirl.berkeley.edu/


More information about the SciPy-user mailing list