Covariance matrix not always positive define

2 Ansichten (letzte 30 Tage)
Gina Carts
Gina Carts am 21 Mär. 2019
Kommentiert: Adam am 21 Mär. 2019
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 Kommentar
Adam
Adam am 21 Mär. 2019
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.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Sparse Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by