|
矩阵的特征值与特征向量
矩阵A 的谱分解为A=UΛU',其中Λ 是由A 的特征值组成的对角矩阵,U 的列为A 的
特征值对应的特征向量,在R中可以用函数eigen()函数得到U和Λ,
> args(eigen)
function (x, symmetric, only.values = FALSE, EISPACK = FALSE)
其中:x为矩阵,symmetric项指定矩阵x是否为对称矩阵,若不指定,系统将自动
检测x是否为对称矩阵。例如:
> A=diag(4)+1
> A
[,1] [,2] [,3] [,4]
[1,] 2 1 1 1
[2,] 1 2 1 1
[3,] 1 1 2 1
[4,] 1 1 1 2
> A.eigen=eigen(A,symmetric=T)
> A.eigen
$values
[1] 5 1 1 1
$vectors
[,1] [,2] [,3] [,4]
[1,] 0.5 0.8660254 0.000000e+00 0.0000000
[2,] 0.5 -0.2886751 -6.408849e-17 0.8164966
[3,] 0.5 -0.2886751 -7.071068e-01 -0.4082483
[4,] 0.5 -0.2886751 7.071068e-01 -0.4082483
> A.eigen$vectors%*%diag(A.eigen$values)%*%t(A.eigen$vectors)
[,1] [,2] [,3] [,4]
[1,] 2 1 1 1
[2,] 1 2 1 1
[3,] 1 1 2 1
[4,] 1 1 1 2
> t(A.eigen$vectors)%*%A.eigen$vectors
[,1] [,2] [,3] [,4]
[1,] 1.000000e+00 4.377466e-17 1.626303e-17 -5.095750e-18
[2,] 4.377466e-17 1.000000e+00 -1.694066e-18 6.349359e-18
[3,] 1.626303e-17 -1.694066e-18 1.000000e+00 -1.088268e-16
[4,] -5.095750e-18 6.349359e-18 -1.088268e-16 1.000000e+00 |
|