math
math copied to clipboard
X_logit_{rng, lpdf, lupdf}(theta) should allow -infinite values in theta
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_rngfunctions to allow -infinity. - [Optional] Allow a single +infinity value to produce a deterministic distribution on that value.
- Remove the bounds check in
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.