Hello Adamo!



 adamoyoung:

I noticed that if I initialize a categorical distribution and try to get its mean with distribution.mean it returns nan. This also happens if you try to get distribution.variance.
Is there a reason that this happens?


Let me speculate:
If you understand your categories – 0, 1, 2, … – to be numerical
values, the mean and standard deviation of the Categorical
distribution make perfectly good sense.
But I imagine people might have been thinking of the of categories
as being more generally non-numerical – cat, dog, bird, … – for which
the mean and standard deviation don’t really make sense.  (What do
you get when you average a cat and a dog?  Answer: A smart dog.)
Looked at this way I could see not implementing mean, etc., or
returning nan for it.  (I would prefer that mean, etc., be implemented
because they do make sense, at least for some use cases.)
Perhaps some forum participant could replace my idle speculation
with the real history and the reason …
Best.
K. Frank