Return Poisson random variate with rate lambda. Works well for lambda < 30 or so. For lambda >> 1 it can produce wrong results due to roundoff error.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(rng_t), | intent(inout) | :: | self | |||
| real(kind=dp), | intent(in) | :: | lambda |
function poisson(self, lambda) result(rr) class(rng_t), intent(inout) :: self real(dp), intent(in) :: lambda integer(i4) :: rr real(dp) :: expl, p expl = exp(-lambda) rr = 0 p = self%unif_01() do while (p > expl) rr = rr + 1 p = p * self%unif_01() end do end function poisson