-
-
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
Improve numerical stability of von_mises_lpdf #3036
Improve numerical stability of von_mises_lpdf #3036
Conversation
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.
Thanks LGTM, will merge once tests pass
Jenkins Console Log Machine informationNo LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.3 LTS Release: 20.04 Codename: focalCPU: G++: Clang: |
Summary
This PR implements the proposal in #3035. The motivation, approach and consequences are described there.
Tests
The existing tests for the von_mises distribution run. No new tests since its a small change to an existing distribution.
Side Effects
As described in #3035, this makes von_mises_lpdf run slightly slower. However, the end result is faster because now the likelihood can be vectorized.
Release notes
Improved stability of the von_mises_lpdf function to avoid numeric overflow. Now it's no longer necessary to use the normal_lpdf for kappa>100, allowing vectorizing the likelihood.
Checklist
[ X] Copyright holder: Vencislav Popov
The copyright holder is typically you or your assignee, such as a university or company. 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/)
[ X] the basic tests are passing
./runTests.py test/unit
)make test-headers
)make test-math-dependencies
)make doxygen
)make cpplint
)[ X] the code is written in idiomatic C++ and changes are documented in the doxygen
[ X] the new changes are tested