-
-
Notifications
You must be signed in to change notification settings - Fork 183
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
Bug fix of issue #3057 Allow zero total count for multinomial RNG #3061
Bug fix of issue #3057 Allow zero total count for multinomial RNG #3061
Conversation
…nd multinomial_logit. Updated comments and docstrings, added unit tests
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: |
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.
Thank you!
Summary
This PR fixes a small bug in
multinomial_rng
andmultinomial_logit_rng
. While the lpmf functions accept a zero count vector, the RNGs do not accept a zero total count. This is fixed by replacingcheck_positive
withcheck_nonnegative
for the parameterN
. In addition the doc strings ofmultinomial_rng
admultinomial_logit_rng
are updated to indicate which exceptions are thrown under what conditions.I've also updated a comment in
dirichlet_multinomial_rng
, which was no longer relevant because of this bug fix.Tests
For both
multinomial_rng
andmultinomial_logit_rng
a test is added (calledRNGZero
) to test that no exceptions are thrown whenN == 0
, and that the result is a zero count vector.Side Effects
There should be no side effects
Release notes
The RNGs for the multinomial and multinomial_logit distributions now accept a zero total count, resulting in a zero integer vector.
Checklist
Copyright holder: Christiaan H. van Dorp
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 test-math-dependencies
)make doxygen
)make cpplint
)the code is written in idiomatic C++ and changes are documented in the doxygen
the new changes are tested