How to troubleshoot "RuntimeWarning: divide by zero encountered in log"

This isn’t the answer, but some thoughts that might help:

The error you’re seeing is thrown inside the StickBreaking class pymc3/transforms.py at d7172c0a1a76301031d1b3b411d00643c416a0c4 · pymc-devs/pymc3 · GitHub which is the transform used by the Dirichlet distribution pymc3/multivariate.py at d7172c0a1a76301031d1b3b411d00643c416a0c4 · pymc-devs/pymc3 · GitHub, which I assume is the primary source of the issue. In that definition you’ll see that a>0, so I hazard a guess that your a is going to zero.

So why might you get a=0? … If your Beta is huge, then a will get very small, but not zero. Possibly there’s a rounding issue but it seems unlikely.

It might help to simplify and test the model with a = pmExponential(... so you can further isolate

2 Likes