[SciPy-Dev] scipy.stats

josef.pktd at gmail.com josef.pktd at gmail.com
Sat Apr 21 17:27:04 EDT 2012


On Sat, Apr 21, 2012 at 5:12 PM, nicky van foreest <vanforeest at gmail.com> wrote:
>> In [11]: from scipy.stats import uniform
>>
>> In [12]: U = uniform(loc = 3, scale = 5)
>>
>> In [13]: U.mean()
>> Out[13]: 5.5
>>
>> In [14]: U.moment(1)
>> Out[14]: 0.5
>>
>> In [15]: U.moment(8)
>> Out[15]: array(0.11111111111111112)
>>
>> First point: why in line 14 is U.moment(1)  not equal to U.mean()? I
>> checked the code on line
>> https://github.com/scipy/scipy/blob/master/scipy/stats/distributions.py#L358
>> to see why, and this explains the result. However, from the doc-string
>> on line https://github.com/scipy/scipy/blob/master/scipy/stats/distributions.py#L129
>> I would expect to see that U.moment(1) = U.mean().

Looks like a bug. And I don't think the test suite checks whether loc
and scale is handled correctly in all code paths.

>
> Interestingly, http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.moment.html

this is empirical moment, a stats function, not for the distribution
non-central for data is just (data**k).mean() if we don't care about ddof.
Do we need a function?


> says that moment() does compute the central moment. However, I need
> the real moments, i.e., E (X^n) = \int x^n dF(x) where F is the
> distribution function of the R.V. X.

the distribution method moment  is non-centered, raw moment.
(It was a bit inconsistent when I went through this, and I think I
decided everywhere on raw moments,)

Josef

> _______________________________________________
> SciPy-Dev mailing list
> SciPy-Dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-dev



More information about the SciPy-Dev mailing list