On Tue, Jan 13, 2009 at 5:11 PM, culpritNr1 <ig2ar-s...@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. Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor