Generates n random numbers with a normal distribution.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=ik), | intent(in) | :: | n |
function randn1d(n) result(r)
!! Generates n random numbers with a normal distribution.
integer(ik), intent(in) :: n
real(rk) :: r(n), r2(n)
call random_number(r)
call random_number(r2)
r = sqrt(-2 * log(r)) * cos(2 * pi * r2)
end function randn1d