Skip to content
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 WishartCholesky and InverseWishartCholesky #1787

Open
sethaxen opened this issue Oct 11, 2023 · 3 comments
Open

Adding WishartCholesky and InverseWishartCholesky #1787

sethaxen opened this issue Oct 11, 2023 · 3 comments

Comments

@sethaxen
Copy link
Contributor

The logpdf function of Wishart computes the Cholesky factorization of the input, while its rand function constructs a Cholesky factor before computing the full matrix, so, like LKJCholesky, it would be convenient to have an implementation of WishartCholesky. This would e.g. allow Turing users to perform inference on parameters with Wishart priors without computing the Cholesky factorization.

Similarly, we could implement an InverseWishartCholesky to avoid Cholesky factorizing the input in logpdf. However, rand does not benefit in this case, since it would be implemented in terms of Wishart, and the Cholesky factorization of the inverse of a matrix is not related to the Cholesky factorization of the matrix.

Side benefits are that random sampling in InverseWishart and MatrixBeta could be sped up using WishartCholesky, though for the latter, this could be a breaking change (currently the struct stores Wishart distributions).

@devmotion
Copy link
Member

Completely agree. I have been thinking about it for a few months but never found the time to put together a PR.

@sethaxen
Copy link
Contributor Author

I have some local implementations I'll polish for a PR. I also looked at the same for MatrixBeta, but there's no way to use the factorization for its logpdf, just rand I think.

@sethaxen
Copy link
Contributor Author

Similarly, we could implement an InverseWishartCholesky to avoid Cholesky factorizing the input in logpdf. However, rand does not benefit in this case, since it would be implemented in terms of Wishart, and the Cholesky factorization of the inverse of a matrix is not related to the Cholesky factorization of the matrix.

I worked out an algorithm for directly sampling the Cholesky factor of Inverse-Wishart without going through Wishart: https://arxiv.org/abs/2310.15884

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

No branches or pull requests

2 participants