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 Center および File ExchangeSparse Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by