[Tutor] Gamma distribution function

Kent Johnson kent37 at tds.net
Tue Jan 13 23:53:36 CET 2009

On Tue, Jan 13, 2009 at 5:11 PM, culpritNr1 <ig2ar-saf1 at yahoo.co.uk> wrote:
> Hi Jarvis,
> I tried the scipy function. I don't understand it. Look, if you go to
> http://en.wikipedia.org/wiki/Poisson_Distribution wiki's Poisson
> distribution documentation  you'll find that this is the naive way to
> compute a Poisson probability mass function
>>>> lam = 1
>>>> k = 2
>>>> math.exp(-lam) * lam**k / factorial(k)
> 0.18393972058572117
> Notice that it matches the figure in the wiki page (the red curve).
> Now, the scipy module does this:
>>>> stats.distributions.poisson.rvs(1, 2)
> array([3])
> The python documentation on this functionality is extremely poor.

See http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.poisson.html

I think you want poisson.pmf(), not poisson.rvs(). See the note at the
bottom of the referenced page. I think rvs() is picking random values
distributed according to the given poisson distribution, that is why
you get different numbers each time.


More information about the Tutor mailing list