为什么 find_MAP 在此模型上抛出错误?

Why does find_MAP throw error on this model?

我正在 pymc3 中尝试一个简单的模型,但是当我尝试使用 find_MAP 方法时它抛出以下错误。:

ValueError: Optimization error: max, logp or dlogp at max have non-finite values. Some values may be outside of distribution support. max: {'theta_stickbreaking': array([  1.90465421e-09,   0.00000000e+00])} logp: array(-inf) dlogp: array([ -1.14279242e-09,   0.00000000e+00])Check that 1) you don't have hierarchical parameters, these will lead to points with infinite density. 2) your distribution logp's are properly specified. Specific issues:

非常相似的代码使用 Beta 和二项式分布而不是 Dirichlet 和多项式分布,但以下代码失败:

from pymc3 import Model
from pymc3 import Metropolis 
from pymc3 import Multinomial, Dirichlet
from pymc3 import sample, find_MAP
from pymc3 import traceplot
from scipy import optimize
import numpy as np

y_obs = [200, 400, 500]
k = 3
a= np.array([1, 1, 1])

with Model() as multinomial_inference:
    n = 1000
    theta = Dirichlet('theta', a, shape=k)
    y = Multinomial('y', n, theta, observed=y_obs)

with multinomial_inference:
    start = find_MAP()
    step = Metropolis([theta])
    trace = sample(10000, step, start)

如何调整模型推理设置以使其不至于崩溃?

我认为问题出在您选择的 y_obsn 值上。 y 的观测值总和应为 n.