ChrisiD
ChrisiD

Reputation: 55

PyMc3: Posterior Predictive Check results in Error

Trying to draw 100 predictive samples from the posterior distribution:

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)

I get the following error:

    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'

I get the same error on other data or using Metropolis. What's the reason for this error? How do I sample it correctly? Tia.

Upvotes: 1

Views: 486

Answers (1)

merv
merv

Reputation: 76700

Update NumPy to at least 1.13, which is when numpy.divmod was introduced.

Upvotes: 2

Related Questions