Normal (Gaussian) random number with specified mean and standard deviation. Uses the Box-Muller transform.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in) | :: | mean |
mean of the distribution |
||
| real(kind=wp), | intent(in) | :: | std_dev |
standard deviation |
function normal(mean, std_dev) real(wp),intent(in) :: mean !! mean of the distribution real(wp),intent(in) :: std_dev !! standard deviation real(wp) :: normal real(wp) :: u1, u2 u1 = max( uniform_random_number(), tiny(1.0_wp) ) u2 = uniform_random_number() normal = mean + std_dev * sqrt(-2.0_wp * log(u1)) * cos(twopi * u2) end function normal