-
Notifications
You must be signed in to change notification settings - Fork 20
Description
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.