Test of whether matrix is Symmetric Positive Definite is giving wrong result when matrix is not symmetric
조회 수: 6 (최근 30일)
이전 댓글 표시
I'm computing a multivariate normal probability density with an estimated covariance matrix as follows:
% Update the conditional likelihood given the data
p_yk_g_seq_Ykm1(j) = mvnpdf(yk, ykp1_est, Sk);
and getting the following error
Error using mvnpdf (line 127)
SIGMA must be a square, symmetric, positive definite matrix.
Here are some checks I did in the debugger when this error occurred:
K>> Sk
Sk =
0.0540 -0.0001
-0.0001 0.0540
K>> issymmetric(Sk)
ans =
logical
0
Clearly it is not symmetric.
But when I tried to check if Sk is symmetic positive definite using the method described here in the documentaion:
K>> try chol(Sk)
disp('Matrix is symmetric positive definite.')
catch ME
disp('Matrix is not symmetric positive definite')
end
ans =
0.2323 -0.0002
0 0.2323
Matrix is symmetric positive definite.
This confused me. What is going on here? Is it non-symmetric or not PD or both?
Looking in the code for mvnpdf it actually uses this check:
[R,err] = cholcov(Sigma,0);
So maybe the method from the documentation page linked above is wrong or out of date?
Or maybe it tests for positive semi-definite but not symmetric positive semi-definite.
댓글 수: 0
채택된 답변
Steven Lord
2022년 11월 8일
From the chol documentation page: "If A is nonsymmetric , then chol treats the matrix as symmetric and uses only the diagonal and upper triangle of A." Is the symmetric matrix generated using the diagonal and upper triangle of your matrix SPD?
I'll ask the documentation staff to take a look at the page to which you linked.
댓글 수: 4
Paul
2022년 11월 9일
I thought the PD and SPD properties are not restricted to symmetric matrices, as previously discussed in this answer thread
Matt J
2022년 11월 9일
The definition of PD and PSD can be extended to non-symmetric matrices, but all of the interesting theorems connecting eigenvalues and determinants to positive-definiteness hold only for symmetric\Hermitian matrices.
추가 답변 (1개)
Matt J
2022년 11월 8일
편집: Matt J
2022년 11월 9일
But when I tried to check if Sk is symmetic positive definite using the method described here in the documentaion:
All of the tests at this link are predicated on the assumption that Sk is already symmetric. In other words, they are really intended as tests of postive or non-negative definiteness, not of symmetry.
Therefore, you should just symmetrize the matrix and be done with it,
Sk=(Sk+Sk.')/2;
This does not change the status of Sk as a PSD or PD matrix.
댓글 수: 3
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!