[SciPy-user] Proper Use of NumPy's eig()
Tue Feb 27 15:11:21 CST 2007
Rich Shepard wrote:
> However, I don't see the answer I expected. My expectation is that all
> values would be in the range [0.00-1.00], but they're not.
> When I print eigE I see:
> (array([ 8.88174744e+00+0.j , 3.54286503e-01+2.48721395j,
> 3.54286503e-01-2.48721395j, -3.11162331e-01+1.00980412j,
> -3.11162331e-01-1.00980412j, -2.79755841e-01+0.46954619j,
> -2.79755841e-01-0.46954619j, -4.08484096e-01+0.j ]),
> array([[ 6.24249034e-01 +0.00000000e+00j,
Without knowing your input, I can't see anything particularly wrong. Unless if E
were real-symmetric (or complex-Hermitian), you are likely to end up with
> Since eig(E) "Return[s] all solutions (lamda, x) to the equation Ax =
> lamda x. The first element of the return tuple contains all the eigenvalues.
> The second element of the return tuple contains the eigenvectors in the
> columns (x[:,i] is the ith eigenvector)."
> I can't interpret the above. If the first tuple has all the Eigenvalues,
> how do I extract the principal Eigenvector from the rest? When I did this
> manually a couple of years ago, I used Octave to calculate the principal
> Eigenvector and the answer was easy for me to see.
I don't think that the notion of a principal eigenvector is well-defined if the
matrix is not symmetric. But if you do have a symmetric matrix:
import numpy as np
from scipy import linalg
eigvals, eigvecs = linalg.eig(E)
i = np.real_if_close(eigvals).argmax()
principal_eigvec = eigvecs[:, i]
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the SciPy-user