[SciPy-user] accuracy of stats.gamma.pdf

josef.pktd@gmai... josef.pktd@gmai...
Thu Jan 29 06:38:43 CST 2009


On Thu, Jan 29, 2009 at 4:48 AM, Nicolas Chopin
<nicolas.chopin@bristol.ac.uk> wrote:
>   Dear list,
> when I compute:
>
> stats.gamma.pdf(5.,2.,5.)
>
> I get:
> array([0.])
>
> whereas the same command in R outputs:
>> dgamma(5.,2.,5.)
> [1] 1.735993e-09
>
> Is this a bug, and then should I report it somewhere?
> Or is it just that scipy's implementation of the gamma pdf is a bit
> less accurate than R's?
>
>  I need to compute log-pdf's, so I need relative accuracy, not absolute
> accuracy;
> but I can implement my own log-pdf routine, of course.
>
> Thank you in advance for your wise replies.
>
>
>
> Nicolas Chopin
>

According to Johnson, Kotz, Balakrishnan gamma.pdf(5.,2.,5.) is zero,
it is at the lower boundary.

But for using log-pdf you might still be better of writing the
log(pdf) directly because you can use directly the expression for log
instead of calculating first exp and then log.

I check it more later today.

Josef


More information about the SciPy-user mailing list