3

在 Eigen 中,有一些建议警告不要明确计算行列式和逆矩阵。

我正在使用正态逆愿望先验分布对多元正态进行后验预测。这可以表示为多元 t 分布。

在多元 t 分布中,您会发现一个术语|Sigma|^{-1/2}(x-mu)^T Sigma^{-1} (x-mu)

我对Eigen一无所知。我可以想象对于一个半正定矩阵(它是一个协方差矩阵),我可以使用 LLT 求解器。

然而,求解器本身没有定义.determinant()和方法。.inverse()我是否必须使用该.matrixL()函数并自己反转对角线上的元素以求逆,以及计算乘积以获得行列式?我想我错过了一些东西。

4

1 回答 1

2

If you have the Cholesky factorization of Sigma=LL^T and want (x-mu)^T*Sigma^{-1}*(x-mu), you can compute: (llt.matrixL().solve(x-mu)).squaredNorm() (assuming x and mu are vectors).

For the square root of the determinant, just calculate llt.matrixL().determinant() (calculating the determinant of a triangular matrix is just the product of its diagonal elements).

于 2016-09-27T22:20:06.430 回答