问题
I've noticed that when using uniform distributions in pymc3, the sampler also scans over an _interval
parameter as well unless a transform is specified for example:
with fitModel6:
normMu = pm.Uniform('normMu',lower=0,upper=1000)
will result in not only sampling over normMu, but also, normMu_interval:
trace plot of interval
trace plot of parameter
Normally, when I am using an uniform prior for scale parameter like a normalization, I will of course sample over the log interval. Is pymc3 handling this for me somehow?
Cheers
回答1:
PyMC3 automatically applies transformations to bounded variables to put them on an unconstrained scale. The code for each transformation is here and a very brief discussion of the automatic transformation of variables is found in the official PyMC3 Tutorial.
Edit
In case the link breaks/moves again, here's the bulk of the info from the Tutorial
In order to sample models more efficiently, PyMC3 automatically transforms bounded RVs to be unbounded.
with pm.Model() as model: x = pm.Uniform('x', lower=0, upper=1)`
When we look at the RVs of the model, we would expect to find
x
there, however:In [16]: model.free_RVs Out[16]: [x_interval__]
x_interval__
representsx
transformed to accept parameter values between -inf and +inf. In the case of an upper and a lower bound, aLogOdd
s transform is applied. Sampling in this transformed space makes it easier for the sampler...
来源:https://stackoverflow.com/questions/34577875/what-are-the-interval-transforms-in-pymc3-for-uniform-distributions