Problem calculating a empirical covariance matrix
Mostrar comentarios más antiguos
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???
Respuestas (1)
Mohammad Sayyafzadeh
el 14 de Feb. de 2012
0 votos
I have a same problem.
Categorías
Más información sobre Linear Algebra en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!