RNEXT
Generates pseudorandom numbers from a mixture of two exponential distributions.
Required Arguments
THETA1 — Mean of the exponential distribution that has the larger mean. (Input)
THETA2 — Mean of the exponential distribution that has the smaller mean. (Input)
THETA2 must be positive and less than or equal to THETA1.
P — Mixing parameter. (Input)
P must be nonnegative and less than or equal to THETA1/(THETA1   THETA2).
R — Vector of length NR containing the random deviates from a mixture of exponentials. (Output)
Optional Arguments
NR — Number of random numbers to generate. (Input)
Default: NR = size (R,1).
FORTRAN 90 Interface
Generic: CALL RNEXT (THETA1, THETA2, P, R [])
Specific: The specific interface names are S_RNEXT and D_RNEXT.
FORTRAN 77 Interface
Single: CALL RNEXT (NR, THETA1, THETA2, P, R)
Double: The double precision name is DRNEXT.
Description
Routine RNEXT generates pseudorandom numbers from a mixture of two exponential distributions. The probability density function is
where p = P, θ1 = THETA1, and θ2 = THETA2.
In the case of a convex mixture, that is, the case 0 < p < 1, the mixing parameter p is interpretable as a probability; and RNEXT with probability p generates an exponential deviate with mean θ1, and with probability 1  p generates an exponential with mean θ2. When p is greater than 1, but less than θ1/(θ1  θ2), then either an exponential deviate with mean θ1 or the sum of two exponentials with means θ1 and θ2 is generated. The probabilities are q = p  (p  1)θ1/θ2 and 1  q, respectively, for the single exponential and the sum of the two exponentials.
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, RNEXT is used to generate five pseudorandom deviates from a mixture of exponentials with means 2 and 1, respectively, and with mixing parameter 0.5.
 
USE RNEXT_INT
USE UMACH_INT
USE RNSET_INT
IMPLICIT NONE
INTEGER ISEED, NOUT, NR
REAL P, R(5), THETA1, THETA2
!
CALL UMACH (2, NOUT)
THETA1 = 2.0
THETA2 = 1.0
P = 0.5
NR = 5
ISEED = 123457
CALL RNSET (ISEED)
CALL RNEXT (THETA1, THETA2, P, R)
WRITE (NOUT,99999) R
99999 FORMAT (' Random deviates from a mixture of exponentials: ', /, &
5X, 5F8.4)
END
Output
 
Random deviates from a mixture of exponentials:
0.0700 1.3024 0.6301 1.9756 0.3716