The safety checks in the current implementations of categorical_logit_rng and multinomial_logit_rng are too strict. The doc says categorical(softmax(x)) is the same as categorical_logit(x), but that's not the case because softmax allows negative infinite inputs.
There are two things to fix:
- Remove the bounds checks in the
X_logit_rng functions to allow -infinity.
- [Optional] Allow a single +infinity value to produce a deterministic distribution on that value. Multiple +infinity values could either throw or you could make it uniform among the +infinity positions. I'm not sure which mesas more sense.
- Remove the bounds check in
X_logit_lpdf and X_logit_lupdf when the argument is a data variable.
- Throw an exception or make the result uniform if all inputs are negative infinity. Again I'm not sure which makes sense.
For 3, we still need to flag cases where the argument is an autodiff variable because the infinite values will wreak havoc with derivatives.
The safety checks in the current implementations of
categorical_logit_rngandmultinomial_logit_rngare too strict. The doc sayscategorical(softmax(x))is the same ascategorical_logit(x), but that's not the case becausesoftmaxallows negative infinite inputs.There are two things to fix:
X_logit_rngfunctions to allow -infinity.X_logit_lpdfandX_logit_lupdfwhen the argument is a data variable.For 3, we still need to flag cases where the argument is an autodiff variable because the infinite values will wreak havoc with derivatives.