如何在python中计算左侧特征向量?
>>> import from numpy as np
>>> from scipy.linalg import eig
>>> np.set_printoptions(precision=4)
>>> T = np.mat("0.2 0.4 0.4;0.8 0.2 0.0;0.8 0.0 0.2")
>>> print "T\n", T
T
[[ 0.2 0.4 0.4]
[ 0.8 0.2 0. ]
[ 0.8 0. 0.2]]
>>> w, vl, vr = eig(T, left=True)
>>> vl
array([[ 0.8165, 0.8165, 0. ],
[ 0.4082, -0.4082, -0.7071],
[ 0.4082, -0.4082, 0.7071]])
这似乎不正确,谷歌对此并不友好!
我的理解是正确的。
但是,您可能会误解它。该numpy的文档都在左边特征向量应该是什么更清楚一点。
最后,要强调的是v由a的右本征向量组成(如右侧)。对于某个数字z满足点(yT,a)= z * yT的向量y被称为a的左本征向量,通常,矩阵的左右本征向量不一定是每个的(可能是共轭的)转置其他。
即您需要将向量转置为vl
。vl[:,i].T
是第i个左特征向量。如果我对此进行测试,我将得出结果是正确的。
>>> import numpy as np
>>> from scipy.linalg import eig
>>> np.set_printoptions(precision=4)
>>> T = np.mat("0.2 0.4 0.4;0.8 0.2 0.0;0.8 0.0 0.2")
>>> print "T\n", T
T
[[ 0.2 0.4 0.4]
[ 0.8 0.2 0. ]
[ 0.8 0. 0.2]]
>>> w, vl, vr = eig(T, left=True)
>>> vl
array([[ 0.8165, 0.8165, 0. ],
[ 0.4082, -0.4082, -0.7071],
[ 0.4082, -0.4082, 0.7071]])
>>> [ np.allclose(np.dot(vl[:,i].T, T), w[i]*vl[:,i].T) for i in range(3) ]
[True, True, True]
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句