Unexpected sampling behaviour

Dear experts,

I am performing some tests with a fairly basic model, where I define the likelihood of a 1-bin distribution and I use a uniform prior. In addition, I introduce a Gaussian nuisance parameter in the likelihood.
This is implemented as follow:

import pymc3 as pm
import numpy as np

model = pm.Model()
with model:
truth = pm.Uniform(‘truth’, lower=0., upper=300.)
gaus = pm.Normal(‘gaus_syst1’, mu=0., sigma=1.0)
pois = pm.Poisson(‘poisson’, mu=truth*(1+0.1*gaus), observed=100)
trace = pm.sample(10000, tune=1000, nuts_kwargs={‘target_accept’:0.95})

print(‘NP mean = {}’.format(np.mean(trace[‘gaus_syst1’])))
print(‘NP rms = {}’.format(np.std(trace[‘gaus_syst1’])))t1’]))

print(‘truth mean = {}’.format(np.mean(trace[‘truth’])))

I get the following results:

NP mean = -0.10184846101085772
NP rms = 1.0066925641532645

truth mean = 103.01576766052715

My expectation is that the maximum of the posterior probability should be at (truth, gaus) = (100, 0), since this should also correspond to the maximum likelihood.
So I can’t understand why the posterior distribution of the gaussian nuisance parameter (mean = -0.1) is shifted with respect to the prior one (mean = 0).

Am I missing something obvious?

Hi,
Do you get any warnings from NUTS when fitting the model?
Theoretically, I’m not sure that the MAP should always correspond to the max likelihood – but this should be confirmed.

Hi,
No, I don’t get any warning when fitting this model with NUTS…
I’m not sure how meaningful this information is, but I have tried to use the find_MAP() function on this model. It actually does find the maximum I expect, i.e. (truth, gaus) = (100, 0).

No warning is a good thing I guess :slight_smile:

  • Have you tried with a more regularizing prior? Like a Gamma, or else
  • Maybe it’s because you just have one observation? Thus, even if your prior is super wide, it can’t be overwhelmed by just one data point. If I’m not mistaken, the max like estimate of your prior is 150, so getting to 103 after sampling means it was moved by the data, but not to the point of completely coinciding with it. This is only conjecture of course.