-
-
Notifications
You must be signed in to change notification settings - Fork 189
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
Fixing negative binomial phi cutoff #1497
Fixing negative binomial phi cutoff #1497
Conversation
…stable/2017-11-14)
…xp1~20180509124008.99 (branches/release_50)
So, fixing the phi cutoff triggered some failures in the finite differences test. I tried to fix those and wrote more tests to make sure I am on the right track. Those tests revealed other issues. I failed to fix all of them so far. In particular, there are numerical differences between the values we compute and what I get from Mathematica and the finite differences test does not pass. |
How far off is the finite diff test? Let me know if I can help somehow with the testing.
|
…gs/RELEASE_500/final)
…gs/RELEASE_500/final)
Will continue the discussion here and not at the issue (hope that's OK). There are currently two failing tests a The numbers I get from Mathematica for the
The Here is the relevant error output from the
And here is from the
The test passed before my code changes, but all the failures are for The full test output is seen in the failed Jenkins build: https://jenkins.mc-stan.org/blue/organizations/jenkins/Math%20Pipeline/detail/PR-1497/9/pipeline/. |
Also, I've run out of both ideas and time to improve the actual computation (if the test failures above are convincing enough to show that it needs improvement). Will be able to work on this more after New Year (unless I'll need very hard to procrastrinate on the stuff I should be doing :-) ). |
OK, obviously, I can't stop procrastrinating :-) For the differences in derivative wrt.
|
So it turns out I was chasing very small errors. Taking absolute tolerance into account (i.e. making the tolerance to be So the only remaining failing test is the finite diff. test. I am not sure what to do about this one. The PR description has been updated to reflect the current situation. |
Implemented gradient wrt. phi for Poisson approximation to make the test pass
…stable/2017-11-14)
@bob-carpenter So that code evolved quite a bit and the required changes to |
I can take the review over if that's convenient since I did the last binomial one |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a quick look and noted a few duplicate variables and wrongly removed headers.
@mcol thanks for catching those - I was obviously sloppy with the merge, sorry for that. I resolved those. |
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
@bob-carpenter can I take this over? |
Yes, please!
…On Mon, Mar 16, 2020 at 6:29 PM Ben Bales ***@***.***> wrote:
@bob-carpenter <https://github.com/bob-carpenter> can I take this over?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1497 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZ2D753ZL3JGTHSICYNBUDRH2R6HANCNFSM4JYRE7UQ>
.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both the comments are optional. I'll merge if you say so. I think it's super adequately tested but it looked like there were a couple things you meant to have there that aren't there.
Quick ping.
I don't think there's a need to add many new tests here if that's what you're getting at! Just those couple things, and really I'd be fine with the pull as-is. |
OK, just added the the test for d/dphi at n = 1. Also the lbeta thing was literally that I had a line of code saying "Delete this once #1679 is merged", so I deleted it :-) Tests pass on my computer, hopefully they pass on Jenkins as well. |
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
Sorry I missed this was blocked on me. |
Summary
This introduces more tests on the behavior of negative binomial 2 distribution when
phi
is large and will try to fix issues discovered along the way. Currently:binomial_coefficient_log
and rearranging some operationsphi
This PR requires the improvements from PR #1614 to be merged before it is merged.
Tests
New tests:
phi
forn > 100000
and largephi
. Importantly, the sign of the derivative does not match (e.g. expected = -3.24e-10, actual = 9e-12), not sure if the complex step or the function is to blame, so I assume it is OK for now.phi
values to cover more of the parameter spacen = 0
andn = 1
(this allows me to test evenmu
andphi
values where Mathematica will not calculate exact solutions).Side Effects
neg_binomial_2_lpmf
is computed changed to improve stability, at the cost of tanglingmu
andphi
together earlier, so less computation can be avoided whenpropto=true
andphi
is fixed.Checklist
Math issue The way neg_binomial_2_lpmf delegates to Poisson is broken #1496
Copyright holder: Institute of Microbiology of the Czech Academy of Sciences
By submitting this pull request, the copyright holder is agreeing to the license the submitted work under the following licenses:
- Code: BSD 3-clause (https://opensource.org/licenses/BSD-3-Clause)
- Documentation: CC-BY 4.0 (https://creativecommons.org/licenses/by/4.0/)
the basic tests are passing
./runTests.py test/unit
)make test-headers
)make doxygen
)make cpplint
)the code is written in idiomatic C++ and changes are documented in the doxygen
the new changes are tested