Problem calculating a empirical covariance matrix

1 view (last 30 days)
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???

Answers (1)

Mohammad Sayyafzadeh
Mohammad Sayyafzadeh on 14 Feb 2012
I have a same problem.

Categories

Find more on Linear Algebra in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!