Is there an easier way to do this so I don’t have type in the parameters of the distribution every time I want save the value of the log prior for a given RV?
Similar idea, but here’s one way to do it that doesn’t require re-typing your parameter values. In my use-case, I needed to generate samples from the prior and store their values:
import pymc3 as pm
from pymc3.distributions import draw_values
with pm.Model() as model:
x = pm.Uniform('x', 1, 5)
y = pm.Normal('y', 0., 2.)
log_prior = [
pm.Deterministic('x_val', x.distribution.logp(x)),
pm.Deterministic('y_val', y.distribution.logp(y)),
]
samples_values = draw_values([x, y] + log_prior,
size=100)