Generates pseudorandom numbers from a standard exponential distribution.
R — Vector of length NR containing the random standard exponential deviates. (Output)
NR — Number of
random numbers to generate. (Input)
Default: NR = size (R,1).
Generic: CALL RNEXP (R [,…])
Specific: The specific interface names are S_RNEXP and D_RNEXP.
Single: CALL RNEXP (NR, R)
Double: The double precision name is DRNEXP.
Routine RNEXP generates pseudorandom numbers from a standard exponential distribution. The probability density function is f(x) = e−x; for x > 0. RNEXP uses an antithetic inverse CDF technique; that is, a uniform random deviate U is generated and the inverse of the exponential cumulative distribution function is evaluated at 1.0 − U to yield the exponential deviate.
Deviates from the exponential distribution with mean THETA can be generated by using RNEXP and then multiplying each entry in R by THETA. The following statements (in single precision using the routine SSCAL (Reference Material)) would yield random deviates from such a distribution:
USE IMSL_LIBRARIES
M
CALL
RNEXP (R,
NR)
CALL SSCAL (NR,
THETA,
R,
1)
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.
In this example, RNEXP is used to generate five pseudorandom deviates from a standard exponential distribution.
USE RNEXP_INT
USE UMACH_INT
USE RNSET_INT
IMPLICIT NONE
INTEGER ISEED, NOUT, NR
REAL R(5)
!
CALL UMACH (2, NOUT)
NR = 5
ISEED = 123457
CALL RNSET (ISEED)
CALL RNEXP (R)
WRITE (NOUT,99999) R
99999 FORMAT (' Exponential random deviates: ', 5F8.4)
END
Exponential random deviates: 0.0344 1.3443 0.2662 0.5633 0.1686
PHONE: 713.784.3131 FAX:713.781.9260 |