math icon indicating copy to clipboard operation
math copied to clipboard

X_logit_{rng, lpdf, lupdf}(theta) should allow -infinite values in theta

Open bob-carpenter opened this issue 6 months ago • 0 comments

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:

  1. Remove the bounds checks in the X_logit_rng functions to allow -infinity.
  2. [Optional] Allow a single +infinity value to produce a deterministic distribution on that value.
  3. Remove the bounds check in X_logit_lpdf and X_logit_lupdf when 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.

bob-carpenter avatar Jun 11 '25 19:06 bob-carpenter