[SciPy-Dev] scipy.stats

nicky van foreest vanforeest at gmail.com
Sun Apr 22 13:28:53 EDT 2012


On 22 April 2012 02:41,  <josef.pktd at gmail.com> wrote:
> On Sat, Apr 21, 2012 at 5:58 PM, nicky van foreest <vanforeest at gmail.com> wrote:
>> On 21 April 2012 23:45,  <josef.pktd at gmail.com> wrote:
>>> On Sat, Apr 21, 2012 at 5:31 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
>>>>
>>>> Might this problem be due to the fact that my ubuntu machine does not
>>>> support the latest version of scipy.stats?
>>>
>>> I'm stil on 0.9 and there is no loc, scale option
>>>
>>>>>> import scipy
>>>>>> scipy.__version__
>>> '0.9.0'
>>>>>> stats.uniform.moment(loc = 3, scale = 5)
>>> Traceback (most recent call last):
>>>  File "<stdin>", line 1, in <module>
>>> TypeError: moment() got an unexpected keyword argument 'loc'
>>>>>> U.moment(1)
>>> 0.5
>>>>>> stats.uniform.moment(1)
>>> 0.5
>>>
>>> Obviously I'm not up to date in this.
>>>
>>> can you try the distribution directly instead of the frozen distribution?
>>
>> I am having the same problems as you, although:
>>
>> In [9]: ? uniform.moment
>> Type:           instancemethod
>> Base Class:     <type 'instancemethod'>
>> String Form:    <bound method uniform_gen.moment of
>> <scipy.stats.distributions.uniform_gen object at 0x2e901d0>>
>> Namespace:      Interactive
>> File:           /usr/lib/python2.7/dist-packages/scipy/stats/distributions.py
>> Definition:     uniform.moment(self, n, *args)
>> Docstring:
>>    n'th order non-central moment of distribution
>>
>>    Parameters
>>    ----------
>>    n: int, n>=1
>>        order of moment
>>
>>    arg1, arg2, arg3,... : array-like
>>        The shape parameter(s) for the distribution (see docstring of the
>>        instance object for more information)
>
>>>> stats.uniform.moment(1, loc=3, scale=1)
> 3.5
>>>> stats.uniform(loc=3, scale=1).moment(1)
> 3.5
>
>>>> import scipy
>>>> scipy.__version__
> '0.10.0b2'
>
>
> version mismatch with new documentation
>
> In the older versions of scipy, the frozen distributions didn't always
> pass on the keywords, loc and scale, so they were just quietly
> ignored.
>
> It looks like now moment handles loc and scale
>
>>>> stats.uniform.mean(1, loc=3, scale=5)
> 5.5
>>>> stats.uniform.moment(1, loc=3, scale=5)
> 5.5
>
>>>> stats.uniform.ppf([0, 1], loc=3, scale=5)
> array([ 3.,  8.])
>>>> stats.uniform.ppf([0, 1], loc=3, scale=5).mean()
> 5.5
>
>
> Josef

Ok. So this is clear now. . Let's try to wrap up the above couple of
mails. The problem with the moments is solved. The point about
rv.dist.b in the examples text is not in my opinion. Is it ok to make
a ticket for this? I'll try to figure out how to do this. Hopefully
this is covered in the doc of Ralf.

BTW. I can also try to repair a few of the tickets. For instance, I
came across a similar problem like the one in
http://projects.scipy.org/scipy/ticket/1493. I think I have a nice
solution for this.



More information about the SciPy-Dev mailing list