Can't sample a Beta(70,70) ! (but a beta(60,60) works ?!)

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 :slight_smile: 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