Covariance matrix not always positive define

조회 수: 1 (최근 30일)
Gina Carts
Gina Carts 2019년 3월 21일
댓글: Adam 2019년 3월 21일
I have used the cov Matlab function to calculate the covariance matrix.
I calculate the covariance matrix inside a loop and this stop by giving me the error "Error using iwishrnd (line 41) Covariance matrix must be symmetric and positive definite."
I printed the covariance matrix to see how it looks like and basically after the second calculation of the covariance the program stopped. Is there any way to control the covariance matrix in order to be always positive define?
covar =
1.1658 0.6780 -0.0203 -0.1593 -0.0339
0.6780 8.0017 -0.3713 0.0057 -0.3568
-0.0203 -0.3713 1.0419 -0.1423 -0.0006
-0.1593 0.0057 -0.1423 1.1528 0.0454
-0.0339 -0.3568 -0.0006 0.0454 0.8498
covar =
1.3151 0.1604 0.1350 0 0
0.1604 1.5119 -0.2529 0 0
0.1350 -0.2529 0.7174 0 0
0 0 0 0 0
0 0 0 0 0
  댓글 수: 1
Adam
Adam 2019년 3월 21일
You can often get away with adding a small value to the leading diagonal, but as with anything that changes your data to avoid issues like dividing by zero, it needs to be carefully considered and may not always work.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Sparse Matrices에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by