stan-dev / math

The Stan Math Library is a C++ template library for automatic differentiation of any order using forward, reverse, and mixed modes. It includes a range of built-in functions for probabilistic modeling, linear algebra, and equation solving.
https://mc-stan.org
BSD 3-Clause "New" or "Revised" License
733 stars 184 forks source link

Update `multi_normal` to call `multi_normal_cholesky` after the cholesky #2544

Open spinkney opened 3 years ago

spinkney commented 3 years ago

The multi_normal lpdf relies on autodiff but the multi_normal_cholesky has derivatives. It makes sense to just call multi_normal_cholesky once the Cholesky decomposition is taken of the covariance matrix in the multi_normal_lpdf to take advantage of those derivatives.

This should be a simple fix.

spinkney commented 3 years ago

The precision parameterization should have derivatives as well. A few ad hoc tests of mine show that the cholesky version is faster than precision, do others see the same?