RNPOI
Generates pseudorandom numbers from a Poisson distribution.
Required Arguments
THETA — Mean of the Poisson distribution. (Input)
THETA must be positive.
IR — Vector of length NR containing the random Poisson deviates. (Output)
Optional Arguments
NR — Number of random numbers to generate. (Input)
Default: NR = size (IR,1).
FORTRAN 90 Interface
Generic: CALL RNPOI (THETA, IR [])
Specific: The specific interface name is S_RNPOI.
FORTRAN 77 Interface
Single: CALL RNPOI (NR, THETA, IR)
Description
Routine RNPOI generates pseudorandom numbers from a Poisson distribution with parameter THETA. THETA, which is the mean of the Poisson random variable, must be positive. The probability function (with θ = THETA) is
f(x) = e−θθx/x!
for x = 0, 1, 2, 
If THETA is less than 15, RNPOI uses an inverse CDF method; otherwise the PTPE method of Schmeiser and Kachitvichyanukul (1981) (see also Schmeiser 1983) is used.
The PTPE method uses a composition of four regions, a triangle, a parallelogram, and two negative exponentials. In each region except the triangle, acceptance/rejection is used. The execution time of the method is essentially insensitive to the mean of the Poisson.
Comments
The routine RNSET can be used to initialize the seed of the random number generator. The routine RNOPT can be used to select the form of the generator.
Example
In this example, RNPOI is used to generate five pseudorandom deviates from a Poisson distribution with mean equal to 0.5.
 
USE RNPOI_INT
USE UMACH_INT
USE RNSET_INT
 
IMPLICIT NONE
INTEGER NR
PARAMETER (NR=5)
!
INTEGER IR(NR), ISEED, NOUT
REAL THETA
!
CALL UMACH (2, NOUT)
THETA = 0.5
ISEED = 123457
CALL RNSET (ISEED)
CALL RNPOI (THETA, IR)
WRITE (NOUT,99999) IR
99999 FORMAT (' Poisson(0.5) random deviates: ', 5I8)
END
Output
 
Poisson(0.5) random deviates: 2 0 1 0 1