PyMc3:后验预测检查结果出错

PyMc3: Posterior Predictive Check results in Error

尝试从后验分布中抽取 100 个预测样本:

data = norm(50,5).rvs(30)
with pm.Model() as model_x:
   mu = pm.Uniform("mu",30,90)
   sigma = pm.HalfNormal("sigma", sd=10)
   dat = pm.Normal("dat", mu=mu, sd=sigma, observed = data)
   trace_x = pm.sample(5000)
   pred = pm.sample_posterior_predictive(trace_x, 100, model_x, size=30)

我收到以下错误:

    AttributeError Traceback (most recent call last)
    <ipython-input-172-9812ddb325e6> in <module>()
    ----> 6     pred = pm.sample_posterior_predictive(trace_x, 100, model_x, size=30)

   .../python2.7/site-packages/pymc3/sampling.pyc in sample_posterior_predictive(trace, samples, model, vars, size, random_seed, progressbar)
       1128         for idx in indices:
       1129             if nchain > 1:
    -> 1130                 chain_idx, point_idx = np.divmod(idx, len_trace)
       1131                 param = trace._straces[chain_idx % nchain].point(point_idx)
       1132             else:

    AttributeError: 'module' object has no attribute 'divmod'

我在其他数据或使用 Metropolis 时遇到同样的错误。 这个错误的原因是什么?如何正确采样?蒂亚

将 NumPy 至少更新到 1.13,这是引入 numpy.divmod 的时候。