Skip to content
Prev 1949 / 63424 Next

Error in ppois function (PR#161)

On Fri, 9 Apr 1999 mh.smith@auckland.ac.nz wrote:

            
The problem is in
The Poisson Distribution

     dpois(x, lambda)
     ppois(q, lambda)
     qpois(p, lambda)
     rpois(n, lambda)

Arguments:

       x: vector of (positive) quantiles.

       p: vector of probabilities.

       n: number of random values to return.

  lambda: vector of positive means.

where q is undefined! It should only be defined for integers. Similarly, x
should only be integers.

It seems better to make ppois defined as the CDF for all q. The code had

    x = floor(x + 0.5);

and that should be something like floor(x + 1e-7).

I've fixed this for 0.64.1, and dpois now warns on non-integer x and,
correctly, gives 0. (Yes, I know S does not warn, but that is taking
silence too far I think.)
Thank you for the nice example, now on the help page.


You did not try pnbinom, which is much more wrong:
[1] 0.3125
[1] 0.3320067
[1] 0.4089029