I'm trying to compute the rate parameter of fake set of poisson data, where I set the parameter.
When I run PyMC the posterior distribution always peaks around the true rate parameter, but never seems to hit it.
For example, in this scenario, the true rate parameter is 10
but the posterior peaks at 10.05.
What have I done wrong? Here's the code:
true_rate = 10
n_obs = 10,000
poisson_accidents = np.random.poisson(true_rate, 10000)
# fit a pymc3 model to get the rate
basic_model = pm.Model()
with basic_model:
lambda_prior = pm.Uniform('lambda_prior',0,20)
#likelihood
Y_obs = pm.Poisson('Y_obs',mu = lambda_prior, observed = poisson_accidents)
with basic_model:
trace = pm.sample(2000,cores = 1,chains = 10,tune = 5000)
pm.traceplot(trace)
plt.show()
EDIT
I have increased the number of iterations as suggested:
with basic_model:
trace = pm.sample(10000,cores = 1,chains = 10,tune = 5000)
pm.traceplot(trace)
plt.show()
This still results in a peak that is not centered at 10:
EDIT 2, 15K samples, peaking at 9.93
Am I just being persnickety, or is there something wrong?