Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for discrete distributions with Inf in their support gives InexactError error #1254

Open
mattiasvillani opened this issue Jan 8, 2021 · 1 comment

Comments

@mattiasvillani
Copy link

Example:
support(Poisson(1)) # gives ERROR: InexactError: trunc(Int64, Inf)

The issue is with the line

support(d::Union{D,Type{D}}) where {D<:DiscreteUnivariateDistribution} = round(Int, minimum(d)):round(Int, maximum(d))

since maximum(Poisson(1)) returns Inf, and round(Int, Inf) gives an InexactError.

One solution is to drop the rounding in the above line, but then the support of a discrete distribution is a RealInterval, which is not great. The root problem is probably that there is no Inf of integer type in Julia.

@devmotion
Copy link
Member

Related: JuliaLang/julia#15562

I think the correct solution would be to use https://github.com/JuliaArrays/InfiniteArrays.jl (or something similar) to represent the support of Poisson.

It seems similarly https://github.com/JuliaMath/IntervalSets.jl and https://github.com/JuliaApproximation/DomainSets.jl could be used to represent the support of continuous distributions (also multivariate ones!) more naturally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants