Generates a Poisson distributed random series.
GRANDPOISSON(length, spacing, lambda)
length |
- |
An integer, the length of the output series. |
spacing |
- |
A real, the spacing (delta x) between points. |
lambda |
- |
Optional. A real, the event rate where |
A series.
grandpoisson(100, 0.01, 2.0)
creates a 100 point, Poisson distributed random series of values from a population where the event rate is 2.0.
x = 0..0.1..30;
lambda = 10;
W1: grandpoisson(50000, 1, lambda);label("Random Poisson")
W2: hist(W1, 100, "prob");label("Histogram")
W3: exp(x*log(lambda) - lambda - gammaln(x+1));overp(W2, lred);label("Poisson Distribution")
W1 contains 50000 samples of Poisson distributed random values with an event rate of 10.
W2 contains a 100 sample normalized histogram of W1.
W3 compares the distribution of the generated Poisson random series to the analytic distribution with an event rate of 10.
For lambda less than 30, GRANDPOISSON uses a pseudo-random number sampling method due to Knuth [1]. For all other values of lambda, a rejection method due to Atkinson is employed [2].
The probability mass function, P(k), for Poisson distributed random values is:
where k is a non-negative integer and λ is the event rate.
For λ the average number of events per interval, P(k) is the probability of observing k events in that interval. For example, if one observes on average 3 accidents per month at a particular traffic intersection, assuming a Poisson model, the probability of observing exactly 4 accidents in a month is:
The cumulative distribution function F(k) is:
where Q is the upper regularized incomplete gamma function implemented by GAMMAINC and ⌊k⌋ is the floor function implemented by FLOOR.
The mean and variance of a Poisson distribution is λ.
The Art of Computer Programming, Volume 2.
Addison Wesley, 1969
The Computer Generation of Poisson Random Variables
Journal of the Royal Statistical Society Series C (Applied Statistics)
Vol. 28, No. 1. (1979)