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

Labelling Improper Distributions (API Feature Request) #37

Open
bhgomes opened this issue Jun 28, 2019 · 1 comment
Open

Labelling Improper Distributions (API Feature Request) #37

bhgomes opened this issue Jun 28, 2019 · 1 comment

Comments

@bhgomes
Copy link

bhgomes commented Jun 28, 2019

I have a need for a correct implementation of improper priors for Turing-based Bayesian inference. By improper I mean that the distribution does not integrate to 1, and in some cases you don't want to disallow the construction of such distributions, but you want to bar the user from sampling from it. The simplest case is Uniform(-Inf, Inf). See the wikipedia entry for more details.

I looked here in Distributions to see if there was a function in the API to tell if a distribution was improper or not. Since I did not find one, I am proposing such an interface:

isproper(distribution, lower, upper) = ...  # to be implemented for each distribution

with helper method

isproper(d::Distribution) = isproper(d, minimum(d), maximum(d))

and some example implementations:

isproper(d::Uniform, lower, upper) = isfinite(max(lower, d.a)) & isfinite(min(upper, d.b))
isproper(d::Normal, _, _) = isfinite(d.σ)
isproper(d::Beta, _, _) = !iszero(d.α) | !iszero(d.β) 
# last one relies on Beta being modified to allow for zero-valued α, β

As with the Beta example above, this may require some restructuring of the allowed parameter values for some distributions.

I am asking for feedback on this interface before I start a PR.

@nickrobinson251
Copy link

nickrobinson251 commented Jul 2, 2019

I wonder if this is something that should be handled by downstream packages (like Turing.jl) or packages dedicated to prior distributions e.g. https://github.com/JuliaStats/ConjugatePriors.jl ?

What would be the advantage of this being in Distributions.jl?

[I am think because this seems specific to the use of prior distributions. As far as I can tell, this package doesn't currently support unnormalised distributions p(X; θ) = p̃(X; θ) / Z(θ) in the sense of a distribution p which is known (or computed) only up to the partition function Z -- which are of interest when Z cannot be computed analytically (or it its too expensive to do so).]

@matbesancon matbesancon transferred this issue from JuliaStats/Distributions.jl Jul 10, 2019
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