Covariance matrix not always positive define
1 次查看(过去 30 天)
显示 更早的评论
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
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 Exchange 中查找有关 Operating on Diagonal Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!