Open simonbyrne opened 5 years ago
I think it only fails if the return value is actually outside the range of Int
:
julia> rand(Poisson(float(typemax(Int64))))
9223372034018728960
julia> rand(Poisson(float(typemax(Int64))))
9223372033786713088
julia> rand(Poisson(float(typemax(Int64))))
ERROR: InexactError: Int64(Int64, 9.223372040475427e18)
PS: Someday somewhere in some parallel universe a rand(Poisson(1.0))
will fail with overflow.
I guess it would be useful to have a rand(::Type{Float64}, d::Poisson)
method that didn't do the conversion to Int
.
It would be nice if this could return a better error message.
Note that the underlying Rmath library actually works in terms of Float64s (see https://github.com/JuliaStats/Rmath-julia/issues/11).