RNLNL
Generates pseudorandom numbers from a lognormal distribution.
Required Arguments
XM — Mean of the underlying normal distribution. (Input)
S — Standard deviation of the underlying normal distribution. (Input)
S must be positive.
R — Vector of length NR containing the random lognormal deviates. (Output)
The log of each element of R has a normal distribution with mean XM and standard deviation S.
Optional Arguments
NR — Number of random numbers to generate. (Input)
Default: NR = size (R,1).
FORTRAN 90 Interface
Generic: CALL RNLNL (XM, S, R [, …])
Specific: The specific interface names are S_RNLNL and D_RNLNL.
FORTRAN 77 Interface
Single: CALL RNLNL (NR, XM, S, R)
Double: The double precision name is DRNLNL.
Description
Routine RNLNL generates pseudorandom numbers from a lognormal distribution with parameters XM and S. The scale parameter in the underlying normal distribution, S, must be positive. The method is to generate normal deviates with mean XM and standard deviation S and then to exponentiate the normal deviates.
With μ = XM and σ = S, the probability density function for the lognormal distribution is
The mean and variance of the lognormal distribution are exp(μ + σ2/2) and exp(2μ + 2σ2) ‑ exp(2μ + σ2), respectively.
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, RNLNL is used to generate five pseudorandom lognormal deviates with μ = 0 and σ = 1.
USE RNLNL_INT
USE UMACH_INT
USE RNSET_INT
IMPLICIT NONE
INTEGER NR
PARAMETER (NR=5)
!
INTEGER ISEED, NOUT
REAL R(NR), S, XM
!
CALL UMACH (2, NOUT)
XM = 0.0
S = 1.0
ISEED = 123457
CALL RNSET (ISEED)
CALL RNLNL (XM, S, R)
WRITE (NOUT,99999) R
99999 FORMAT (' Lognormal random deviates: ', 5F8.4)
END
Output
Lognormal random deviates: 7.7801 2.9543 1.0861 3.5885 0.2935