-
-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
neg_binomial_2_log_lpmf is not stable for large phi #1495
Comments
#1496 seems related as the phi cutoff for when to delegate to Poisson is probably not correctly chosen. |
Is it possible to pin down the part of |
@jtimonen You are correct, my work with the non-log version in #1497 shows that the Poisson branch can be eliminated with a better implementation of Sorry that I wasted your time as this connection was not apparent in the issue here. |
If I read this right, then you are suggesting to improve the lgamma implementation... I do doubt that there are issues of these sort of. We are using the So before you embark on this, please test the lgamma if it is really not precise enough. |
I see. Being smart about sums of lgamma sounds like a good approach. Sorry.. I am out of context. This is super tedious work you are looking into here. So much appreciated. Some people quoted me for knowing these things... not really, I just have dealt with a few of these hiccups whenever I had to. |
Description
For some values,
neg_binomial_2_log_lpmf
would return values larger than 0 (e.g.neg_binomial_2_log_lpmf(39, 4, 6e16) == 256
) for other, it just returns noticeably different values than the correspondingneg_binomial_2_lpmf
call. In all cases this is related to largephi
values (noticeable discrepancies manifest already at aroundphi = 2e5
).This seems to be related to/a regression of #428
Example
neg_binomial_2_log_lpmf(39, 4, 6e16) == 256
.I've created a failing test on the branch: develop...martinmodrak:bugfix/1495-neg_binomial_2_log_large_phi
Expected Output
The same as
neg_binomial_2_lpmf(39, exp(4), 6e16)
, which is-5.22991
Current Version:
v3.0.0
The text was updated successfully, but these errors were encountered: