0
votes

Hi everybody I have this problem:

  • I have Dataset of n vectors each has D dimensions.
  • I also have a covariance matrix of size D*D, Let It be C.

I perform the following action:

  • I choose K vectors from the dataset, and also choose E dimensions randomly. Let M be the sample covariance of the selected data on the selected dimensions.so M is a E*E matrix.
  • let P be the partial covariance matrix corresponding to the dimensions E of C, ie. C(E,E) in matlab

is the following matrix positive semi definite?:

X = (1-a)P + aM

where a is a constant like 0.2.

I sometimes get the following error when using mvnrnd(mean,X) : SIGMA must be a symmetric positive semi-definite matrix

My code is:

%%%Dims are randomly choosen dimensions
%%%Inds are randomly choosen Indexes form {1, 2, ...,n}
%%% PP are n D dimensional vectors, composing my data set PP is n*D
%%% Sigmaa is a D*D covariance matrix
co = cov(PP(Inds,Dims));
me = mean(PP(Inds,Dims));
Bettaa = 0.2;
sigmaaDims = sigmaa(Dims,Dims);
sigmaaDims = (1-Bettaa)*sigmaaDims + (co)*Bettaa;
Tem = mvnrnd(me,sigmaaDims);
1
Convex (and conical) combinations of positive semi-definite matrices are positive semi-definite (just expand the definition of X in v'Xv). So your question boils down to whether the (symmetric) matrices P and M are both positive semidefinite. - Ben Voigt
Thank you Ben , But as I said M is sample covariance so it ought to be positive semidefinite. And P is partial matrix obtained from projecting dimensions E form a positive semidefinite matrix. so the question is: is P always positive semidefinit, the second question is if so why matlab keep erroring and how I can prevent this? - Reza_va
Just to confirm, your constant a is always between 0 and 1, right? - Ben Voigt
yes, in fact always 0.2 - Reza_va
I didint understand ur last question well, "you need ALL eigenvalues to be non-negative, not just one?" But, I am not much of math and I always had problems with eigenvalues ;) but I added my code for further detailes - Reza_va

1 Answers

0
votes

Simply looking at the matrix dimensions It is not possible to tell if a matrix is positive semi-definite.

To find out if a given matrix is positive semi-definite, you must check if It's eigenvalues are non-negative and it's symmetry:

symmetry = issymmetric(X);
[~,D]=eig(X);
eigenvalues = diag(D);
if all(eigenvalues>0) & symmetry
    disp('Positive semi-definite matrix.')
else
     disp('Non positive semi-definite matrix.')
end

Where X is the matrix you are interested in.

Note that if you use the weaker definition of a positive definite matrix (see Extention for non symmetric matrices section), X does not need to be symmetric and you would end up with:

[~,D]=eig(X);
eigenvalues = diag(D);
if all(eigenvalues>=0)
    disp('Positive semi-definite matrix.')
else
     disp('Non positive semi-definite matrix.')
end