An error of matrix inversion using NumPy

Robin Becker robin at reportlab.com
Wed Apr 4 11:49:03 EDT 2007


lancered wrote:
> Here is the eigenvalues of KK  I obtained:
> 
>  >>> linalg.eigvals(KK)
> array([  1.11748411e+05,   3.67154458e+04,   3.41580846e+04,
>          2.75272440e+04,   2.09790868e+04,   1.86242332e+04,
>          8.68628325e+03,   6.66127732e+03,   6.15547187e+03,
>          4.68626197e+03,   3.17838339e+03,   2.84888045e+03,
>          1.88279736e+03,   1.32427574e+03,   1.04946287e+03,
>          5.79303171e+02,   3.83111876e+02,   4.93826556e-12,
>          1.50263232e-12])
> 
> You are right. The ratio of max/min eigenvalues is 7.4368432669e+016
> Maybe this exceed the of precision of my machine?
> 
> Is there any tricks for me to be able to deal with this matrix
> correctly with
> NumPy?
> 
.......

You have to be very careful with a set of eigenvalues like the above. The 
implication is that you have a rank deficiency of two ie either you have to 
small a number of observations or there's something fishy about the model (two 
of the data matrix columns can be written as linear combinations of the others 
or  two of the columns are structurally zero). If you really believe the data to 
be good then normalize to unit column length first ie try using

[d(1)/||d(1)||.....d(n)/||d(n)||]

and see if the eigenvalues are still zero (this will only be of benefit if the 
data is vastly different in scale).

I often got bad results, but that was mostly bad programming and or measuring 
the voltage of the earth wire by mistake :). Some problems naturally have a zero 
at the origin.
-- 
Robin Becker




More information about the Python-list mailing list