Open sethaxen opened 2 years ago
I'm afraid this get's a bit specific/opinionated for what DensityInterface is supposed to do. Sometimes you need a transformation to a unconstraint space, sometimes to a constraint space (e.g. the unit hypercube), etc. - this is beyond the scope of DensityInterface. Densities also don't necessarily have constrained parameters by themselves: In a Bayesian scenario, for example, a likelihood may be well-defined over an unconstraint space, but the problem may live on a constraint space due to the choice of prior.
That doesn't mean that there shouldn't be interfaces for this: Default unconstrained transformations of distributions (and maybe measure in general in the future?) are the domain of Bijectors.jl, for example.
I'm also preparing a package VariateTransformations.jl that breaks out generic distribution/variate transformation code from BAT.jl into a standalone package. This will give implicit access to space constraints as long as initial/prior distributions are known for the parameters, via transformation to both uniform and Gaussian spaces.
In addition, the question of support/domain of functions (and their results?) is of course a very general one that extends beyond (log-)densities. I think there a several attempts to define interfaces in the ecosystem at the moment (@devmotion , do you have a list?), but no consensus yet, as far as I know.
The idea behind DensityInterface is to have something really small, lightweight and non-opinionated, to facilitate wide adoption.
ChangesOfVariables.jl implements an interface for performing a transformation and getting the corresponding log-density adjustment needed. This is implemented by a number of packages, including TransformVariables.jl and Bijectors.jl.
It would be handy if the API in this package included API functions like the following:
If the resulting transformation is required to implement the ChangesOfVariables API, then this would allow a function to generically transform a constrained density to an unconstrained one, e.g. for sampling or optimization (an enhancement to the ChangesOfVariables API is needed to "invert" the transformation).