Open sethaxen opened 1 year ago
Completely agree. I have been thinking about it for a few months but never found the time to put together a PR.
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.
Similarly, we could implement an
InverseWishartCholesky
to avoid Cholesky factorizing the input inlogpdf
. However,rand
does not benefit in this case, since it would be implemented in terms ofWishart
, 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
The
logpdf
function ofWishart
computes the Cholesky factorization of the input, while itsrand
function constructs a Cholesky factor before computing the full matrix, so, likeLKJCholesky
, it would be convenient to have an implementation ofWishartCholesky
. 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 inlogpdf
. However,rand
does not benefit in this case, since it would be implemented in terms ofWishart
, 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
andMatrixBeta
could be sped up usingWishartCholesky
, though for the latter, this could be a breaking change (currently the struct storesWishart
distributions).