Domanda

I have this matrix:

S=   6.84370358358718e-006    -7.45833473076585e-007
    -7.45833473076565e-007     7.11723106043725e-006

It is symmetric:

S-S'=                     0    -2.00111533788828e-020
      2.00111533788828e-020                         0 

and is positive definite:

eig(S)= 6.22219831321029e-006    and     7.73873633081414e-006

When I use [a b]=cholcov(S), it returns returns a=[] and b=NaN. It is written in MatLab help that[T,num] = cholcov(SIGMA) ... If SIGMA is not square and symmetric, num is NaN and T is empty.

Of course the chol(S) function decomposes this function without any error. I don't know the difference between chol and cholcov and it is not important, since I don't have any choices. The error comes from mvnrnd(zeros(1,2),S) function, when I try to generate some random numbers:

??? Error using ==> mvnrnd at 118
SIGMA must be a symmetric positive semi-definite matrix.

Can anyone tell me what's wrong here? thanks.

È stato utile?

Soluzione 2

You wrote:

S-S'=                     0    -2.00111533788828e-020
      2.00111533788828e-020                         0 

That says that S is not symmetric. It's ALMOST symmetric. But... not quite. If this is due to numerics, you might be able to fix this with:

symmetricS = mean(cat(3,S,S'),3);

Altri suggerimenti

It is NEARLY symmetric. You yourself admit that it is NOT symmetric. Is being ALMOST pregnant the same thing as pregnant? You show that S~=S'. The fix is easy.

S = (S + S')/2;
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top