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

49 views (last 30 days)
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

Accepted Answer

Walter Roberson
Walter Roberson on 26 Feb 2013
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;
  6 Comments
Abinaya Sankarakumar
Abinaya Sankarakumar on 20 Sep 2020
I use mvnrnd to generate a normal distribution . But when I find its mean I get different value from the one I used . Why is it so ?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!