Return two normal random variates with mean 0 and variance 1. http://en.wikipedia.org/wiki/Marsaglia_polar_method
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(rng_t), | intent(inout) | :: | self |
function two_normals(self) result(rands) class(rng_t), intent(inout) :: self real(dp) :: rands(2), sum_sq do rands(1) = 2 * self%unif_01() - 1 rands(2) = 2 * self%unif_01() - 1 sum_sq = sum(rands**2) if (sum_sq < 1.0_dp .and. sum_sq > 0.0_dp) exit end do rands = rands * sqrt(-2 * log(sum_sq) / sum_sq) end function two_normals