In an attempt to solve a more complex model, I have created simple toy model below. It uses a categorical prior and Poisson prior distribution. It seems to me that the chain should converge on 6, that is twice the obs value, but it does not move from zero. I feel I must have overlooked something very obvious, as I have used categorical priors before.
import numpy as np
from pymc3 import *
from pymc3.distributions.discrete import Poisson, Categorical
import theano
import theano.tensor as tt
%matplotlib inline
import matplotlib
import matplotlib.pyplot as plt
def run_true_MCMC(n, obs, draws):
obs = np.array(obs)
with Model() as model2:
pn = np.ones(n) / n
print(pn)
tmx = Categorical('tmx', pn)
tmx = tmx * 0.5
#tmx_print = tt.printing.Print('tmx')(tmx)
sfs_obs = Poisson('sfs_obs', mu=tmx, observed=obs)
with model2:
trace = sample(draws, tune=0) #Will set to CategoricalGibbsMetropolis
plt.show(forestplot(trace, varnames=['tmx']))
traceplot(trace, varnames=['tmx'])
print(summary(trace, varnames=['tmx']))
return trace
obs = 3
draws = 100000
n = 10
trace = run_true_MCMC(n, obs, draws)