Getting 'Bad initial energy: inf' when trying to sample simple model

Hi @Stargrazer82301, this is actually one of our FAQs. You can have a look at the answer here:

For example, in your case, running:

for RV in model.basic_RVs:
    print(RV.name, RV.logp(model.test_point))

gives:

Intercept 1.1370228148748596
Gradient -inf
Psi_log__ -0.7257913526447277
z_likelihood 73.49976264100106

And looking closer at gradient:

gradient = pm.Normal('Gradient', mu=leastsq_fit[0], sd=leastsq_fit[0], testval=leastsq_fit[0])

You can see that sd is defined as leastsq_fit[0], which is a negative value.

I am actually surprise that Metropolis can sample - it should not be the case…

2 Likes