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!
np.diag(cov)
look like? – behzad.nouricov
generated? – Warren Weckesser