[SciPy-User] gamma ppf weirdness

josef.pktd at gmail.com josef.pktd at gmail.com
Wed Nov 25 01:44:47 EST 2009


On Wed, Nov 25, 2009 at 1:30 AM, Art Poon <artpoon at gmail.com> wrote:
> Hello,
> I'm trying to hammer out some quick simulation code and need to calculate a
> bunch of inverse CDF values from the gamma distribution.  SciPy seems like a
> great resource for this.  However, I've encountered some strangeness that is
> probably my own fault:
>>>> g = stats.gamma(1,0,1)
>>>> g
> <scipy.stats.distributions.rv_frozen object at 0x1b9b2b0>
>>>> g.ppf(0.1)
> 0.10536051565782635
>>>> g.ppf(0.25)
> 0.0
>>>> g.ppf(0.2500001)
> 0.28768220578512327
>>>> g.ppf(0.2499999)
> 0.28768193911845646
>>>> g.ppf(0.25)
> 0.0
> I'm just dying to know where I've gone wrong here!  In the meantime, I'm
> coding up a function to compute the inverse CDF from MATLAB code.
> I'm using Snow Leopard with Python 2.5.4 (bypassing default system Python
> 2.6.1), numpy-1.3.0 and scipy-0.7.1, both compiled from source.
> Thanks!
> - Art.

this has been fixed in trunk, see http://projects.scipy.org/scipy/ticket/975

>>> stats.gamma.ppf(0.25, 1.,0.,1)
0.28768207245178096
>>> stats.gamma.ppf(0.2500001, 1.,0.,1)
0.28768220578512327
>>> stats.gamma.ppf(0.25 -0.00001, 1.,0.,1)
0.28766873920733566
>>> stats.gamma.ppf(0.25, 1,0,1)
0.28768207245178096
>>> stats.gamma(1,0,1).ppf(0.25)
0.28768207245178096
>>> import scipy
>>> scipy.version.version
'0.8.0.dev6118'


Josef

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



More information about the SciPy-User mailing list