필터 지우기
필터 지우기

error message in using mvnrnd function??

조회 수: 2 (최근 30일)
arkedia
arkedia 2013년 2월 12일
i'm craeting a gibbs sampling algorithm and the fdollowing message appears when i'v used mvnrnd function :
??? Error using ==> mvnrnd SIGMA must be a symmetric positive semi-definite matrix.
note i'v used chol function befor using mvnrnd
nu02=chol(nu01); nu0=s*nu02; z = mvnrnd(mu0,nu0)'; what can i do to solve the problem?
  댓글 수: 1
the cyclist
the cyclist 2013년 2월 12일
It's pretty hard to say anything here without more details. Do you have a very small example of nu01 and s that you can provide, that exhibits the error?

댓글을 달려면 로그인하십시오.

채택된 답변

Tom Lane
Tom Lane 2013년 2월 12일
Using chol is a good idea, but chol does not actually check that the matrix is symmetric:
>> a = [2 1;1 3]
a =
2 1
1 3
>> chol(a)
ans =
1.4142 0.7071
0 1.5811
>> a(2,1) = 0;
>> chol(a)
ans =
1.4142 0.7071
0 1.5811|
You might want to look at nu01-nu01' to see if the matrix is not symmetric. If the lack of symmetry is just the result of roundoff error, consider
nu01 = (nu01 + nu01') / 2;

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Particle & Nuclear Physics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by