Symmetric Positive Semi-definate Covariance matrix using mvnrnd
4 views (last 30 days)
Show older comments
I'm having an issue using mvnrnd. My covariance matrix is,
SIGMA = [12.96 14.076 0 0 0 0 0 0 0 0 0 0; 14.076 21.16 21.114 0 0 0 0 0 0 0 0 0; 0 21.114 29.16 27.54 0 0 0 0 0 0 0 0; 0 0 27.54 36 25.5 0 0 0 0 0 0 0; 0 0 0 25.5 25 17 0 0 0 0 0 0; 0 0 0 0 17 16 12.24 0 0 0 0 0; 0 0 0 0 0 12.24 12.96 9.792 0 0 0 0; 0 0 0 0 0 0 9.792 10.24 8.16 0 0 0; 0 0 0 0 0 0 0 8.16 9 8.415 0 0; 0 0 0 0 0 0 0 0 8.415 10.89 16.83 0; 0 0 0 0 0 0 0 0 0 16.83 36 28.05; 0 0 0 0 0 0 0 0 0 0 28.05 30.25]
All my eigenvalues are positive, and the matrix is symmetric, as far as I can tell, yet whenever I attempt to generate my RV's:
clear clc SIGMA = [12.96 14.076 0 0 0 0 0 0 0 0 0 0; 14.076 21.16 21.114 0 0 0 0 0 0 0 0 0; 0 21.114 29.16 27.54 0 0 0 0 0 0 0 0; 0 0 27.54 36 25.5 0 0 0 0 0 0 0; 0 0 0 25.5 25 17 0 0 0 0 0 0; 0 0 0 0 17 16 12.24 0 0 0 0 0; 0 0 0 0 0 12.24 12.96 9.792 0 0 0 0; 0 0 0 0 0 0 9.792 10.24 8.16 0 0 0; 0 0 0 0 0 0 0 8.16 9 8.415 0 0; 0 0 0 0 0 0 0 0 8.415 10.89 16.83 0; 0 0 0 0 0 0 0 0 0 16.83 36 28.05; 0 0 0 0 0 0 0 0 0 0 28.05 30.25] mu = [.9 2.3 5 12.5 8.8 -2 -4.3 -2.5 -1.5 .2 3.8 4.3] r = mvnrnd(mu, SIGMA, 2000)
I receive this error message.
??? Error using ==> mvnrnd at 118 SIGMA must be a symmetric positive semi-definite matrix.
Thanks for the help! David
0 Comments
Accepted Answer
More Answers (1)
Jurgen
on 18 Nov 2012
isequal(sum(eig(SIGMA)>0),length(eig(SIGMA)))
Why does eig(SIGMA) give negative eigenvalues?
0 Comments
See Also
Categories
Find more on Mathematics and Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!