Slice sampling can get stuck


There are 3 while loops in astep() in pymc3/step_methods/ on lines 56, 58, and 62. These can get stuck for a very long time if given an oddly shaped distribution.

The simplest fix for this is to add some sort of loop counter that throws an error when a max iterations limit has been exceeded. A quick implementation of this can be found in:

However, the original Neal (2003) paper also describes a window doubling procedure that would not be as prone to getting stuck. Perhaps that should be the fall back mode?

Maybe there is a way to fall back to a random walk Metropolis step if slice sampling gets stuck and still maintain detailed balance?


That’s a good idea. PR welcome.