math icon indicating copy to clipboard operation
math copied to clipboard

Fix `gamma_lccdf` actually

Open spinkney opened this issue 1 month ago • 0 comments

See https://discourse.mc-stan.org/t/possible-issue-with-gamma-lccdf/

The function gamma_lccdf results in numerical instability for alpha approximately greater than 30. It’s due to gamma_q or grad_reg_inc_gamma. I can rewrite this to use gamma_p and grad_reg_lower_inc_gamma, which avoids potential instability in a tgamma(alpha) and digamma(alpha) call. It seems to sample a bit faster than just wrapping gamma_lcdf with log1m_exp.

Will put the PR in this week.

spinkney avatar Dec 09 '25 12:12 spinkney