This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Matrix : Full Rank and Determinant equal to Zero

Tags: None
(comma "," separated)
agaz1985
Registered Member
Posts
3
Karma
0
Hi,
i'm using Eigen3 to compute the inverse matrix of a covariances matrix P.
Tipically P is singular so I compute the inverse (or pseudo-inverse) using SVD decomposition and the code used in this post : http://eigen.tuxfamily.org/bz/show_bug.cgi?id=257.
Apparently it works well but i have a problem.
Just for check, before computing the pseudo-inverse, I print out the determinant and the rank of the matrix P using this code :

Eigen::FullPivLU<Eigen::MatrixXd> lu_decomp(P);
std::cout << Determinant is " << A.determinant() << std::endl;
std::cout << "The rank of P is " << lu_decomp.rank() << std::endl;
std::cout << "The size of P is " << P.rows() " x " << P.cols() << std::endl;

In some cases (most of them) I obtain for example:

Detrminant is 0
The rank of P is 60
The size of P is 60x60

or

Detrminant is -0
The rank of P is 72
The size of P is 72x72

I think it is wrong, because if I have a full rank matrix its determinant should not be zero. Any suggest ?

Thank's All.
Angelo.
dmbates
Registered Member
Posts
24
Karma
0
OS
This doesn't directly answer your question but a covariance matrix is positive semidefinite so wouldn't you be better off using a LDLT decomposition instead of an LU? The LDLT decomposition is not necessarily rank-revealing but the number of diagonal elements greater than a threshold times the largest diagaonal element is a good indication of the rank. The determinant of A is simply the product of the diagonal elements of D, which are retrieved with the .vectorD() method.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Perhaps the computation of the determinant underflow. For instance imagine a 50x50 diagonal matrix with all the elements around 1e-8. Without additional information, i.e., a relevant non zero reference value, the matrix is full rank but the determinant is 1e-(8*50) which is exactly 0 using double precision numbers.
ErlendA
Registered Member
Posts
12
Karma
0
OS
Compute the log-determinant instead. Perform Cholesky factorisation and sum the elements: $\log \det (A) = \sum_{i=0}^{n-1} 2*\log(L_{ii})$. After that exponentiate the result to get $\det(A)$


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]