For probabilistic programming in particular, it’s critical to be able to use distribution-related functions (especially
logpdf) in non-standard ways. For example, I would love to be able to call
logpdf(TDist(nu),x) where nu and/or x have type
It seems there are at least two things that get in the way:
- checks like
Distributions.@check_argsthat can’t be determined statically
- type constraints like
Neither of these is in itself a bad thing. But it seems critical to have an easy workaround for both.
For the first case, one idea is for Distributions.jl to have an unexported “unsafe” kernel
_logpdf with no check. Then the exported
logpdf could wrap this in the appropriate check. It may be possible to use a similar trick to have something available without the type constraint, but this is less clear to me. Of course it would be better to be able to force other libraries’ types to be
::Real (if they really ought to be), but I don’t know that this can be done without either lots of forking or lots of wrappers.
If Distributions.jl isn’t general-purpose, people will write their own alternatives, and we’ll have lots of duplicated effort. There’s already some of this - I had to fork Distributions to get it to play nice with SymPy, and (as I understand it) the Gen team built their own version of it to have nice gradients.
Does an approach like the above make sense, or would it break other things? Is there a better way to go about it? Are there other capabilities specific to probabilistic programming that Distributions.jl should provide?