且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

numPy中的意外特征向量

更新时间:2023-02-26 15:06:37

您只是误解了eig的返回.根据文档,第二个返回参数是

You are just misinterpreting eig's return. According to the docs, the second return argument is

归一化的(单位长度")特征向量,例如列 v [:,i]是对应于特征值w [i]的特征向量.

The normalized (unit "length") eigenvectors, such that the column v[:,i] is the eigenvector corresponding to the eigenvalue w[i].

因此对应于特征值1的特征向量不是[ 0.4472136 , -0.70710678],而是[-0.70710678, -0.70710678],可以很容易地验证:

So the eigenvector corresponding to eigenvalue 1 is not [ 0.4472136 , -0.70710678], but [-0.70710678, -0.70710678], as can be easily verified:

>>> markov.dot([ 0.4472136 , -0.70710678]) # not an eigenvector
array([ 0.21634952, -0.59167474])
>>> markov.dot([-0.70710678, -0.70710678]) # an eigenvector
array([-0.70710678, -0.70710678])