MATLAB: SIGMA must be a symmetric positive semi-definite matrix error in matlab

digital image processing

HI all, I have been trying to use the mvnrnd function to generate samples of alpha using the truncated gaussian distribution.mvnrnd function needs sigma which must be positive semi-definite and symmetric.My matrix is 1.0e-006 *
0.3822 0 0 0.1831 0 0 0
0 0.2081 0.0417 0 0.0759 0 0.0426
0 0.0417 0.3505 0 0 0.1096 0
0.1831 0 0 0.2050 0 0.0492 0
0 0.0759 0 0 0.0721 0 0.0220
0 0 0.1096 0.0492 0 0.1952 0
0 0.0426 0 0 0.0220 0 0.0903
the matrix is as per requirements bt still i m still getting the error.Any suggestions will be of great help.
Thanks
wid regards,
Ekta

Best Answer

Your matrix is probably not exactly right due to round-off. For example have a look at
YourMatrix - YourMatrix.'
and you will likely see some non-zero values.
The usual trick is to use
YourMatrix = (YourMatrix + YourMatrix.') / 2;