-
Notifications
You must be signed in to change notification settings - Fork 46
simulate_log_normal
Fabian Kindermann edited this page Apr 1, 2021
·
4 revisions
subroutine simulate_log_normal(x, mu, sigma, fixed)
Simulates independent draws from a random variable following a log-normal distribution with mean and variance .
-
real*8 :: x
orreal*8 :: x(:)
The subroutine stores the realizations of the draws from the random variable in the scalar or one-dimensional arrayx
. Ifx
is a scalar, the subroutine only draws one realization. Ifx
is a one-dimensional array, the subroutine fills up all the array elements with independent draws from the random variable.
-
real*8 :: mu
The mean of the distribution. If not present, the subroutine uses . Note that this input variable needs to be strictly greater than zero. -
real*8 :: sigma
The variance of the distribution. If not present, the subroutine uses . Note that this input variable needs to be strictly greater than zero. -
logical :: fixed
If a logical variablefixed
is passed to the subroutine that takes the value.true.
, the subroutine uses a fixed random seed. As a result, the sequence of random numbers drawn by the subroutine will always be the same every time your program is restarted. Iffixed
is not present or takes a value of.false.
, then the random seed is initialized at some arbitrary value that depends on the time and date at which you started your program. Hence, the series of random numbers drawn by this subroutine will be different every time your program is restarted.
- Parts of this routine were copied and adapted from:
- The GNU gfortran compiler documentation for the initialization of the seed of the random number generator.
- For further reading refer to:
- Toral, R. & Colet, P. (2014). Stochastic Numerical Methods: An Introduction for Students and Scientists. Weinheim: Wiley.
- Box, G.E.P., Muller, M.E. (1958). A Note on the Generation of Random Normal Deviates, The Annals of Mathematical Statistics, 29(2), 610–611.
- This routine is used in the following programs:
prog02_16.f90