X_logit_{rng, lpdf, lupdf}(theta) should allow -infinite values in theta
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 839
- Forks
- 220
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 14
Description
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. 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_lpdfandX_logit_lupdfwhen 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the implementations of categorical_logit_rng, multinomial_logit_rng, and the X_logit_lpdf/lupdf functions, then inspect their current bounds checks and how they distinguish data from autodiff arguments. Determine and document behavior for negative infinity, positive infinity, and all-negative-infinity inputs before changing the checks. Done means data arguments accept the supported infinite values, autodiff arguments remain protected, and tests cover the selected edge-case behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100