Skip to content

Conversation

@syclik
Copy link
Member

@syclik syclik commented Jan 19, 2024

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, and wishart_cholesky_lpdf. This also affects the random number generators for inv_wishart_cholesky_rng, multi_normal_cholesky_rng, and wishart_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

    • unit tests pass (to run, use: ./runTests.py test/unit)
    • header checks pass, (make test-headers)
    • dependencies checks pass, (make test-math-dependencies)
    • docs build, (make doxygen)
    • code passes the built in C++ standards checks (make cpplint)
  • the code is written in idiomatic C++ and changes are documented in the doxygen

  • the new changes are tested

@syclik
Copy link
Member Author

syclik commented Jan 19, 2024

This PR overtakes #3002

}

return mdivide_left_tri_low(B, L_S);
return mdivide_right_tri_low(L_S, B);
Copy link
Member Author

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?

@spinkney
Copy link
Collaborator

spinkney commented Jan 19, 2024 via email

@syclik
Copy link
Member Author

syclik commented Jan 20, 2024

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.

@syclik
Copy link
Member Author

syclik commented Jan 20, 2024

@WardBrian, this is ready to be merged! #3002 passes all tests.

@spinkney spinkney merged commit 695e45b into staging/v4.8.1 Jan 20, 2024
@syclik syclik deleted the feature/check_choleksy_factor_4.8.1 branch January 21, 2024 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants