[英]In which order eigen values repeated in np.linalg.eig?
Documentation says that eigenvalues are repeated according to its multiplicity and the are not ordered. 文档说,特征值根据其多重性重复,并且不排序。 When I print w it gives me [5,3,5,1]. 当我打印w时,它会给我[5,3,5,1]。 Why eigenvalues appear in this order. 为什么特征值按此顺序出现。 What is the storing order for eigen vectors? 特征向量的存储顺序是什么? Is it same as for eigenvalues? 与特征值相同吗?
B = np.array([[5,-2,6,-1],[0,3,-8,0],[0,0,5,4],[0,0,0,1]])
print(B)
print(B.shape)
w, v= np.linalg.eig(B)
print("eigenvalues are: ", w)
Yes the eigenvectors will be in the same order, you can verify this by adding just two lines to your code 是的,特征向量的顺序相同,您可以通过在代码中仅添加两行来验证这一点
import numpy as np
B=np.array([[5,-2,6,-1],[0,3,-8,0],[0,0,5,4],[0,0,0,1]])
print(B)
print(B.shape)
w,v= np.linalg.eig(B)
print("eigenvalues are: ", w)
for i in range(4):
print (np.dot((B-w[i]*np.eye(4)),v[:,i]))
As far as the concept of multiplicity is concerned, a single eigenvalue can be associated with multiple linearly independent eigenvectors. 就多重性的概念而言,单个特征值可以与多个线性独立的特征向量相关联。 You can read more about this here 您可以在此处了解更多信息
The documentation provides the following information regarding the eigenvectors. 该文档提供了有关特征向量的以下信息。
The normalized (unit “length”) eigenvectors, such that the column v[:,i] is the eigenvector corresponding to the eigenvalue w[i]. 归一化的(单位“长度”)特征向量,使得列v [:,i]是对应于特征值w [i]的特征向量。
In other words, the order of eigenvalues is arbitrary in principle. 换句话说,特征值的顺序原则上是任意的。 But whatever order of the eigenvalues, the order will match the eigenvectors. 但是,无论特征值的顺序如何,该顺序都将与特征向量匹配。
You can verify that the eigenvalues and eigenvector orders match by computing the application of B
to the column vectors of v
. 您可以通过计算B
对v
的列向量的应用来验证特征值和特征向量顺序是否匹配。 In code, 在代码中
for i in range(B.shape[0]):
# Apply B to the eigenvectors
scaled = np.dot(B, v[:, i])
# Check that applying B only applies a scaling to the eigenvector
np.testing.assert_allclose(scaled, w[i] * v[:, i])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.