log1p_exp() for logistic_lcdf() and logistic_lccdf()
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 839
- Forks
- 220
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 14
Description
Description
The logistic_lcdf() and logistic_lccdf() function break down at standardised values beyond 36 or so, due to numerical underflow (e.g., here and here).
This underflow can be solved by using log1p_exp() in the implementation instead of computing the CDF/CCDF directly.
I don't understand the full complexity of the templates in stan-math enough to make a pull request – sorry! – but I think this should be a pretty quick fix for anybody who understands the library well.
Example
Stan returns -Inf for log_lccdf(40 | 0, 1)...
Expected Output
...whereas -log1p_exp(40) evaluates cleanly to -40.
Current Version:
v4.4.0
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 reading the linked calculations in stan/math/prim/prob/logistic_lcdf.hpp and stan/math/prim/prob/logistic_lccdf.hpp, then trace the existing log1p_exp() implementation. Confirm the change avoids underflow for standardized values such as 40 and produces the expected finite result of -40.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100