RANDOM_NPP Function
Generates pseudorandom numbers from a nonhomogeneous Poisson process.
Usage
result = RANDOM_NPP(tbegin, tend, ftheta, theta_min, theta_max, neub)
Input Parameters
tbegin—Lower endpoint of the time interval of the process. tbegin must be nonnegative. Usually, tbegin = 0.
tend—Upper endpoint of the time interval of the process. tend must be greater than tbegin.
ftheta—Scalar string specifying a user-supplied function to provide the value of the rate of the process as a function of time. This function accepts one argument and must be defined over the interval from tbegin to tend and must be nonnegative in that interval.
theta_min—Minimum value of the rate function ftheta() in the interval (tbegin, tend). If the actual minimum is unknown, set theta_min = 0.0.
theta_max—Maximum value of the rate function ftheta in the interval (tbegin, tend). If the actual maximum is unknown, set theta_max to a known upper bound of the maximum. The efficiency of RANDOM_NPP is less the greater theta_max exceeds the true maximum.
neub—Upper bound on the number of events to be generated. In order to be reasonably sure that the full process through time tend is generated, calculate neub as neub = X + 10.0 * SQRT(X), where X = theta_max * (tend - tbegin).
Returned Value
One-dimensional array containing times to events. If the length of result is less than neub, the time tend is reached before neub events are realized
Input Keywords
Double—If present and nonzero, double precision is used.
Discussion
Routine RANDOM_NPP simulates a one-dimensional nonhomogeneous Poisson process with rate function theta in a fixed interval (tend - tbegin).
Let λ(t) be the rate function and t0 = tbegin and t1 = tend. Routine RANDOM_NPP uses a method of thinning a nonhomogeneous Poisson process {N*(t), t ≥ t0} with rate function λ*(t) ≥ λ(t) in (t0, t1), where the number of events, N*, in the interval (t0, t1) has a Poisson distribution with parameter:
The function:
is called the integrated rate function. In RANDOM_NPP, λ*(t) is a constant λ*(= theta_max) so that at time ti, the time of the next event ti + 1 is obtained by generating and cumulating exponential random numbers:
with parameter λ*, until for the first time:
where the uj,i are independent uniform random numbers between 0 and 1.
This process is continued until the specified number of events, neub, is realized or until the time, tend, is exceeded. This method is due to Lewis and Shedler (1979), who also review other methods. The most straightforward (and most efficient) method is by inverting the integrated rate function, but often this is not possible.
If theta_max is actually greater than the maximum of λ(t) in (t0, t1), the routine will work, but less efficiently. Also, if λ(t) varies greatly within the interval, the efficiency is reduced. In that case, it may be desirable to divide the time interval into subintervals within which the rate function is less variable. This is possible because the process is without memory.
If no time horizon arises naturally, tend must be set large enough to allow for the required number of events to be realized. Care must be taken, however, that ftheta is defined over the entire interval.
After simulating a given number of events, the next event can be generated by setting tbegin to the time of the last event (the sum of the elements in the result) and calling RANDOM_NPP again. Cox and Lewis (1966) discuss modeling applications of nonhomogeneous Poisson processes.
Example
In this example, RANDOM_NPP is used to generate the first five events in the time 0 to 20 (if that many events are realized) in a nonhomogeneous process with rate function:
λ (t) = 0.6342 exp(0.001427t)
for 0 < t ≤ 20.
Since this is a monotonically increasing function of t, the minimum is at t = 0 and is 0.6342, and the maximum is at t = 20 and is 0.6342 exp(0.02854) = 0.652561.
.RUN
- FUNCTION ftheta_npp, t
- RETURN, .6342*exp(.001427*t)
- END
; % Compiled module: FTHETA_NPP.
RANDOMOPT, set=123457
neub = 5
tmax = .652561
tmin = .6342
tbegin=0
tend=20
r = RANDOM_NPP(tbegin, tend, 'ftheta_npp', tmin, tmax, neub)
PM, r ; PV-WAVE prints the following:
; 0.0526598
; 0.407979
; 0.258399
; 0.0197666
; 0.167641