How can I define a custom likelihood in PyMC3? In PyMC2, I could use @pymc.potential
. I tried to use pymc.Potential
in PyMC3, however, it seems that boolean operations cannot be applied to the parameters (I get an error like this when I do that). For example, following code does not work:
from pymc import *
with Model() as model:
x = Normal('x', 1, 1)
def z(u):
if u > 0: #comparisons like this are not supported
# if theano.tensor.lt(0,u): this is how comparison should be done
return u ** 2
return -u**3
x2 = Potential('x2', z(x))
start = model.test_point
h = find_hessian(start)
step = Metropolis(model.vars, h)
sample(100, step, start)
It's not possible for me to change all the comparisons inside the likelihood to the Theano syntax (i.e., theano.tensor.{lt,le,eq,neq,gt,ge}). Is there anyway to use define a likelihood function similar to PyMC2?