Normal deviate from a PCG32 generator.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(pcg32_t), | intent(inout) | :: | gen |
Generator, advanced by exactly two draws. |
||
| real(kind=dp), | intent(in) | :: | mu |
Mean. |
||
| real(kind=dp), | intent(in) | :: | sigma |
Standard deviation. |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=dp), | private | :: | u1 | ||||
| real(kind=dp), | private | :: | u2 |
function pcg32_next_normal_dp(gen, mu, sigma) result(r) !! Normal deviate from a PCG32 generator. type(pcg32_t), intent(inout) :: gen !! Generator, advanced by exactly two draws. real(dp), intent(in) :: mu !! Mean. real(dp), intent(in) :: sigma !! Standard deviation. real(dp) :: r real(dp) :: u1, u2 u1 = 1.0_dp - next_real_dp(gen) u2 = next_real_dp(gen) r = mu + sigma*sqrt(-2.0_dp*log(u1))*cos(TWO_PI*u2) end function pcg32_next_normal_dp