Problem calculating a empirical covariance matrix
Afficher commentaires plus anciens
Hello,
I am trying to compute an empirical covariance matrix from a sample matrix. I need to use it later on with other function which calls chol. The data is 16 dimensional. I tried the following:
D = size(SAMPLE_MATRIX,2); COV = zeros(D,D); for i = 1:D COV = COV + SAMPLE_MATRIX(:,i)*SAMPLE_MATRIX(:,i)'; end COV = COV/D;
However, COV is not positive definite at the end (it has a large first positive eigenvalue and then negative eigenvalues of the order exp(-20)). Consequently I cannot use this matrix as a covariance matrix in the chol (or cholcov) function.
I tried the most obvious cov(SAMPLE_MATRIS'), with the same result. Am I doing something wrong, or there is a problem in how matlab computes covariances???
Réponses (1)
Mohammad Sayyafzadeh
le 14 Fév 2012
0 votes
I have a same problem.
Catégories
En savoir plus sur Linear Algebra dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!