Reputation: 595
I must be missing something here. I can calculate the log probability from a Normal distribution, but not a Uniform distribution:
>>> import pymc as pm
>>> with pm.Model():
... b = pm.Normal('b', 0, 1)
...
>>> b.logp({'b': 2)
array(-2.9189385332046727)
>>> with pm.Model():
... a = pm.Uniform('a', 0, 1)
...
>>> a.logp({'a': 0.5})
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'TransformedRV' object has no attribute 'logp'
Upvotes: 1
Views: 706
Reputation: 2070
PyMC3 transform bounded distributions, like the uniform, to unbounded ones. So you could ask PyMC3 to do not transform the variable:
with pm.Model() as model:
a = pm.Uniform('a', 0, 1, transform=None)
a.logp({'a': 0.5})
or ask for the transformed variable like:
with pm.Model() as model:
a = pm.Uniform('a', 0, 1)
model.logp({'a_interval__': 0.5})
You may want to check the unobserved_RVs
and free_RVs
attributes of model
Upvotes: 2