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 tha
You need to use the DensityDist function to wrap your log likelihood. From the examples bundled with the source:
with Model() as model:
lam = Exponential('lam', 1)
failure = np.array([0, 1])
value = np.array([1, 0])
def logp(failure, value):
return sum(failure * log(lam) - lam * value)
x = DensityDist('x', logp, observed=(failure, value))
You can make arbitrary non-Theano deterministics using the @theano.compile.ops.as_op decorator, but not as easily for Stochastics.