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
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