Possible Bug in DiscreteUniform?

Hi Pymc3 Team.
I’m posted here first, as this error could easily be caused by something silly on my end.
I have a model sampling from a DiscreteUniform(lower=0, upper=4), but I’m getting negative values returned?

Here is the notebook + data: markers.csv (8.0 MB)

What you can’t see in the notebook, is w_printed contains -ve values right before the chain crashes:
w_printed str = [ 0 1 0 0 1 1 0 0 1 1 -1 0 -2 1 1 0 0 -1 0 2 2 1 0 2
0 -1 2 -2 2 1 0 2 3 0 2 3 2 3 0 0 0 2 0 0 -1 2 -1 0
3 0 3 1]

FYI, the traceplot in the notebook is from a previous model and can be ignored.

Because you are using metropolis sampler on a discrete latent bounded variable, it sometimes purpose value that is outside of the support of the RV. Depends on the use case, it either get rejected because the value is invalid, or throws an error (if eg you are using the discrete variable to do indexing).

Ah, ok so its related to this pymc2 issue.
So im thinking of solving it by taking the absolute value of w, which will then not trigger the error, but will trigger a rejection. Is there a cleaner way?

Taking the absolute value of w would not help, as the error is likely coming from the sampler. You should try using a categorical distribution

Thanks!