Hi,
I have a RV that is related to an other RV via a deterministic relation. I would like to display its pdf but it seems that it hasn’t the distribution
attribute. Is there a solution to go around this problem?
Here is a simple example to illustrate what I try to achieve:
import pymc3 as pm
from matplotlib import pyplot as plt
import numpy as np
with pm.Model() as model:
rv1= pm.Normal('rv1', 6.9., 1.)
rv2 = pm.Deterministic('rv2', pm.math.exp(rv1))
_, ax = plt.subplots(1, 2, figsize=(15, 5))
x = np.linspace(0, 10, 100)
y = np.exp(model.named_vars['rv1'].distribution.logp(x).eval()) # This works!!!
ax[0].plot(x, y)
ax[0].set_xlabel('rv1')
ax[0].set_title('Prior on rv1')
x = np.linspace(0, 10000, 100)
y = np.exp(model.named_vars['rv2'].distribution.logp(x).eval()) # This does not work!!!!! :-(
ax[0].plot(x, y)
ax[0].set_xlabel('rv2')
ax[0].set_title('Prior on rv2')