-
-
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
adding input checks for cholesky factors #3007
Conversation
…. New code properly catches the error.
This PR overtakes #3002 |
@@ -47,7 +45,7 @@ inline Eigen::MatrixXd inv_wishart_cholesky_rng(double nu, | |||
B(j, j) = std::sqrt(chi_square_rng(nu - k + j + 1, rng)); | |||
} | |||
|
|||
return mdivide_left_tri_low(B, L_S); | |||
return mdivide_right_tri_low(L_S, B); |
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.
@spinkney, this is correct, right?
Yes, that's right 👍
…On Fri, Jan 19, 2024, 2:08 PM Daniel Lee ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In stan/math/prim/prob/inv_wishart_cholesky_rng.hpp
<#3007 (comment)>:
> @@ -47,7 +45,7 @@ inline Eigen::MatrixXd inv_wishart_cholesky_rng(double nu,
B(j, j) = std::sqrt(chi_square_rng(nu - k + j + 1, rng));
}
- return mdivide_left_tri_low(B, L_S);
+ return mdivide_right_tri_low(L_S, B);
@spinkney <https://github.com/spinkney>, this is correct, right?
—
Reply to this email directly, view it on GitHub
<#3007 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFU3D6PIL7VVEFBQ5NONNETYPLOFBAVCNFSM6AAAAABCCREMKKVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTQMZTG4ZDKNZVGI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Much thanks to @sethaxen for discovering a problem with the rngs, @spinkney for pushing for a solution, and @WardBrian for helping with the trickier parts of expressions in this PR. |
@WardBrian, this is ready to be merged! #3002 passes all tests. |
Summary
We weren't checking cholesky factors in the code in multivariate distributions. This appeared in a user-facing RNG generating NaN for all quantities.
The fix here is to validate input arguments.
Tests
No new tests.
For anyone reviewing, if it makes sense, please let me know what should be tested.
Side Effects
Some existing models may no longer work if they accept matrixes and compute something (even if it's non-sensical) based on the inputs.
Release notes
Bug fix. Added checks for Cholesky factors in multivariate distributions. This fixes issues in
inv_wishart_cholesky_lpdf
,lkj_corr_cholesky_lpdf
,multi_gp_cholesky_lpdf
,multi_normal_cholesky_lpdf
, andwishart_cholesky_lpdf
. This also affects the random number generators forinv_wishart_cholesky_rng
,multi_normal_cholesky_rng
, andwishart_cholesky_rng
.Checklist
Copyright holder: Daniel Lee
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/)
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