[SciPy-dev] bug in scipy.stats package
josef.pktd@gmai...
josef.pktd@gmai...
Fri Jan 8 11:40:59 CST 2010
On Fri, Jan 8, 2010 at 11:56 AM, Leon Adams <skorpio11@gmail.com> wrote:
>
> Hi all,
> I am currently doing some work involving distribution fitting and it looks
> like a came across a strange bug in the ppf function of the gamma
> distribution. Can some one else verify and if so suggest possible
> resolution. Below is a sample of my python script:
>
> import scipy.stats as st
> import numpy as np
> nbins = 12
> binProb = np.zeros(nbins) + 1.0/nbins
> binSumProb = np.add.accumulate(binProb)
> print binSumProb
> print st.gamma.ppf(binSumProb,0.6379,loc=1.6,scale=39.555)
>
> With the following output:
> [ 0.08333333 0.16666667 0.25 0.33333333 0.41666667 0.5
> 0.58333333 0.66666667 0.75 0.83333333 0.91666667 1. ]
> [ 2.28713122 3.68072087 1.6 8.20183111 11.42062087
> 15.44977132 20.5371578 27.11627185 36.01838095 49.13633397
> 72.58240868 Inf]
My result look correct, see below. Which version of scipy are you using?
I think this was http://projects.scipy.org/scipy/ticket/975
which would mean the fix is only in trunk
Thanks for reporting it
Josef
>>> scipy.version.version
'0.8.0.dev6156'
>>> import scipy.stats as stats
>>> import numpy as np
>>> nbins = 12
>>> binProb = np.zeros(nbins) + 1.0/nbins
>>> binSumProb = np.add.accumulate(binProb)
>>> print binSumProb
[ 0.08333333 0.16666667 0.25 0.33333333 0.41666667 0.5
0.58333333 0.66666667 0.75 0.83333333 0.91666667 1. ]
>>> print stats.gamma.ppf(binSumProb,0.6379,loc=1.6,scale=39.555)
[ 2.28713122 3.68072087 5.64774079 8.20183111 11.42062087
15.44977132 20.5371578 27.11627185 36.01838095 49.13633397
72.58240868 Inf]
>
> The problem occurs at an input value of 0.25, the ppf returns the location
> parameter (in this case 1.6)
>
> Thanks in advance
> --
> Leon Adams
>
> _______________________________________________
> SciPy-Dev mailing list
> SciPy-Dev@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-dev
>
>
More information about the SciPy-Dev
mailing list