Implement default_transform
and transform
argument for distributions
#5674
Labels
default_transform
and transform
argument for distributions
#5674
Discussed in #5404
Most of the times when users apply a custom transform, they do it because they want to "distort" the base distribution (i.e., to impose ordering, sum to a constant, centered parametrization). This however, overrides default transforms that are set for constrained distributions, leading to inefficient sampling.
The correct thing to do in this case would be the Chain the default transform with the new one, so that the "distorted" distribution is still stable during sampling. However, this is pretty verbose and most users are not even aware of the default transform behavior.
The proposed solution is to implement a new transform keyword
default_transform
, that behaves liketransform
now does. Thetransform
keyword, if set, would then be chained together with whatever thedefault_transform
is (or used as is when a distribution does not have a default transform).If users want to disable any transform whatsoever, they will now have to set
default_transform
toNone
. This is usually only done for pedagogical reasons. We can detect if users are trying to do this the old way, when they settransform=None
(the default is a flag variableUNSET
), and raise an error that explains the changed behavior. Settingtransform=None
would never have an effect because that is always the default behavior.In addition we can use this information raise a warning when users do prior predictive, which are generally invalid for "distorted" distributions. This is very similar to what we already do for models containing
Potentials
for the very same reasonspymc/pymc/sampling.py
Lines 2014 to 2020 in 80b5e86
The text was updated successfully, but these errors were encountered: