Closed ANaka closed 5 years ago
Interesting -- I had no idea about the automatic re-scaling.
I was hoping to be able to stick with pm.Categorical
, since it's so flexible, and as much as possible only ever use pm.DiscreteUniform
among the other discrete RV choices, but I think that was a bad call.
I will probably have to rewrite a chunk of the slides to talk explicitly about Bernoulli variables to make this work.
The latest version of pyMC3 allows for Categorical
s with exact 0
entries, so I think I'll ignore this subtlety for now.
Maybe not a big deal but you might run into some trouble with pm.Categorical() since it's a bit confusing how it is set up and IMO not rigid enough in enforcing what its args are supposed to be.
One way to solve the hw problem is this:
But IIRC, this is not best practice for using pm.Categorical - you are not supposed to pass any 0s in as arguments. I forget why, I think it has something to do w/ rescaling the probability mass function, and I think what happens in practice is that if you do this, the 0 gets changed to a very small nonzero value. So if you adhere to what's in the docstring, then the only way to make a categorical dist that produces 1 every time is something like
Probably this is all just splitting hairs, but highlights something else that might not be clear - the output of pm.Categorical during the sampling is an integer indexing the categories. This is something that, again, is not super straightforward to figure out from the doc strings if you just do
?pm.Categorical
so might be worth stating this