Generates a vector of random variates from a lognormal distribution with probability density function, \(f (X)\), where:
\[f(X) = \frac{e^{-\frac{(\log X - \mu)^2}{2\sigma^2}}}{X \sigma \sqrt{2\pi}}\]
if X > 0, otherwise \(f (X) = 0\). Here μ is the mean, (XMU ) and \(\sigma 2\) the variance, (VAR) of the underlying Gaussian distribution.
C Generate 100 values from the Lognormal distribution
INTEGER LSTATE,N
PARAMETER (LSTATE=16,N=100)
INTEGER I,INFO,SEED(1),STATE(LSTATE)
DOUBLE PRECISION XMU,VAR
DOUBLE PRECISION X(N)
C Set the seed
SEED(1) = 1234
C Read in the distributional parameters
READ(5,*) XMU,VAR
C Initialize the STATE vector
CALL DRANDINITIALIZE(1,1,SEED,1,STATE,LSTATE,INFO)
C Generate N variates from the Lognormal distribution
CALL DRANDLOGNORMAL(N,XMU,VAR,STATE,X,INFO)
C Print the results
WRITE(6,*) (X(I),I=1,N)