1
votes

I have a 336x336 coinsurance matrix and I calculated the eigenvalues and eigenvectors using numpy as follows with sorting.

evals, evecs = np.linalg.eig(cov)
idx = evals.argsort()   
evals = evals[idx] 
evecs = evecs[:,idx]

The problem is that the last value in evals is strange compared to other values. Something like this:

    evals[:3]
    [ -6.11117191e-19  -6.11117191e-19  -1.08420217e-19]
    evals[-3:]
    [  4.29345466e-19   7.08196415e-19   1.69419875e-02]

The highest eigenvalue, 1.69419875e-02, is very high compared to other values. I have checked all the 336 eigenvalues and all except this one is more or less in same range.

Can anyone tell me why is this so.

Hi mrcl, Thank you for your reply. I have generated the 8x8 covariance matrix using precision suggested by you. It now looks like this:

[[  0.00e+00   0.00e+00   0.00e+00   0.00e+00   0.00e+00   0.00e+00   0.00e+00   0.00e+00]
  [  0.00e+00   4.62e-05   9.25e-05   4.62e-05   0.00e+00  -9.25e-05  -4.62e-05  -4.62e-05]
  [  0.00e+00   9.25e-05   1.85e-04   9.25e-05   0.00e+00  -1.85e-04  -9.25e-05  -9.25e-05]
  [  0.00e+00   4.62e-05   9.25e-05   4.62e-05   0.00e+00  -9.25e-05  -4.62e-05  -4.62e-05]
  [  0.00e+00   0.00e+00   0.00e+00   0.00e+00   0.00e+00   0.00e+00   0.00e+00   0.00e+00]
  [  0.00e+00  -9.25e-05  -1.85e-04  -9.25e-05   0.00e+00   1.85e-04   9.25e-05   9.25e-05]
  [  0.00e+00  -4.62e-05  -9.25e-05  -4.62e-05   0.00e+00   9.25e-05   4.62e-05   4.62e-05]
  [  0.00e+00  -4.62e-05  -9.25e-05  -4.62e-05   0.00e+00   9.25e-05   4.62e-05   4.62e-05]]

For column 1 and row 1, I am not sure why all is zero, I calculated manually also the covariance of these column and row and it is zero only, may be there is not much change in the original values, The original values are:

0.06  0.05  0.05  0.08  0.05  0.06  0.06  0.02

0.06  0.04  0.03  0.07  0.05  0.08  0.07  0.03

Thanks!

2
what is "coinsurance matrix"?behzad.nouri
This is a math question not a programming question. I've flagged it and suggested it is moved to math.stackexchange.com.TooTone
also how does np.diag(cov) look like?behzad.nouri
It could be that all but one of the eigenvalues are 0, and what you are seeing is numerical noise. How is cov generated?Warren Weckesser

2 Answers

1
votes

It means all of your eigenvalues are zero, except one. I think your matrix may not be a full rank matrix.

0
votes

@newbie

Based on the 8x8 matrix I noticed a pattern of zero rows and columns which repeats every fourth column or row. Whenever a column or a row of a matrix is full with zeros, this makes the determinant to be zero and the matrix is singular, therefore your cov matrix has no inverse. In this case, the returned eigenvalues are the same as the singular values from the singular value decomposition(SVD).

I would recommend you to double check the reason why the calculation of your covariance matrix leads to rows and columns full of zeros, even in the main diagonal.

Hope it helps.