4

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

J. Michael
  • 41
  • 4

1 Answers1

5

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__ represents x transformed to accept parameter values between -inf and +inf. In the case of an upper and a lower bound, a LogOdds transform is applied. Sampling in this transformed space makes it easier for the sampler...

nbrunett
  • 129
  • 2
  • 9
aloctavodia
  • 2,040
  • 21
  • 28