While trying some experiment about beta distributions I found thid weird behaviour…
This code works :
with pm.Model() as model:
r0 = pm.Beta('r0',alpha=1+60,beta=1+60)
trace = pm.sample(chains=1)
_ = pm.traceplot(trace)
,
But this one, just changing the alpha & beta params from 60 to 70 :
with pm.Model() as model:
r0 = pm.Beta('r0',alpha=1+70,beta=1+70)
trace = pm.sample(chains=1)
_ = pm.traceplot(trace)
fails with a : “ValueError: Bad initial energy: nan. The model might be misspecified.”
I don’t understand why !? And this is even more strange :
r0 = pm.Beta('r0',alpha=1+999,beta=1+999)
works !!
Why certain specific parameter values range seem to have problem ?
Any help appreciated.
Hm, I can’t seem to reproduce this, that’s really interesting.
Perhaps “bad initial energy” means that the sampler is trying to start in a region of zero probability density. Since this Beta has such tight tails, could it be that an initialization outside roughly (0.3, 0.7) is causing that problem?
Interesting hypothesis, but then :
r0 = pm.Beta('r0',alpha=1+999,beta=1+999)
Should be even harder to sample !! (but it works perfectly…)
Yeah, I can’t explain that one Perhaps there’s randomness in the initialization? I may just be making that up, though, I could be completely wrong here.
Can you rerun the Beta(70, 70) and see if it still fails?
1 Like
I’ve restarted my computer, and I still have this weird behavior !
[…]
And if I change the beta distribution parameters to : (60,60)… it works fine :
I have no clue !! Except that it seems not to happen on a another computer (thank @tushar_chandra), which is a nice thing, but I still find this worrying for a futur use of pymc3 in production…)
I have not been able to reproduce. Have you tried using different random seeds when calling pm.sample
? Or set a different start
and init
combination?
No seed where specified , so I guess the starting point is different for each run.
(I run both version several time with the same weird behavior…)
I have the final answer for that bug !!
I had the latest numpy installed instead of numpy-1.14.3 (recommanded for pymc3).
uninstall numpy then re-install numpy-1.14.3, and this bug desappears…
1 Like