Custom likelihood in pymc3

痴心易碎 提交于 2019-11-30 14:06:27

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!