Thanks for your help. However, I am still experiencing problems when using the new distribution as a prior. You can reproduce the error I get by using
import pymc as pm
import numpy as np
import arviz as az
def mvlognormal_dist(mu, cov, size):
return pm.math.exp(pm.MvNormal.dist(mu, cov, size=size))
class MvLogNormal:
def __new__(cls, name, mu, cov, **kwargs):
return pm.CustomDist(name, mu, cov, dist=mvlognormal_dist, ndim_supp=1, **kwargs)
@classmethod
def dist(cls, mu, cov, **kwargs):
return pm.CustomDist.dist(mu, cov, class_name="MvLogNormal", dist=mvlognormal_dist, ndim_supp=1, **kwargs)
with pm.Model() as m:
x = MvLogNormal("x", mu=np.zeros(3), cov=np.eye(3)*1e-3)
y = pm.MvNormal("y", mu=x, cov=np.eye(3), observed=np.exp([1, 2, 3]))
trace = pm.sample(chains=1, step=pm.Metropolis())
az.summary(trace)