eigen()R語言中的函數用於計算矩陣的特征值和特征向量。特征值是縮放特征向量的因子。
用法: eigen(x)
參數:
x:矩陣
範例1:
# R program to illustrate 
# Eigenvalues and eigenvectors of matrix 
    
# Create a 3x3 matrix 
A = matrix(c(1:9), 3, 3) 
  
cat("The 3x3 matrix:\n") 
print(A) 
    
# Calculating Eigenvalues and eigenvectors 
print(eigen(A)) 輸出:
The 3x3 matrix:
     [, 1] [, 2] [, 3]
[1, ]    1    4    7
[2, ]    2    5    8
[3, ]    3    6    9
eigen() decomposition
$values
[1]  1.611684e+01 -1.116844e+00 -5.700691e-16
$vectors
           [, 1]       [, 2]       [, 3]
[1, ] -0.4645473 -0.8829060  0.4082483
[2, ] -0.5707955 -0.2395204 -0.8164966
[3, ] -0.6770438  0.4038651  0.4082483
範例2:
# R program to illustrate 
# Eigenvalues and eigenvectors of matrix 
    
# Create a 3x3 matrix 
A = matrix(c(2, 3, 5, 1), 2, 2) 
A 
    
# Calculating Eigenvalues and eigenvectors 
print(eigen(A)) 輸出:
     [, 1] [, 2]
[1, ]    2    5
[2, ]    3    1
eigen() decomposition
$values
[1]  5.405125 -2.405125
$vectors
          [, 1]       [, 2]
[1, ] 0.8265324 -0.7503320
[2, ] 0.5628892  0.6610612
相關用法
- R語言 is.matrix()用法及代碼示例
- R語言 data.matrix()用法及代碼示例
- R語言 as.matrix()用法及代碼示例
- R語言 str_detect()用法及代碼示例
- R語言 determinant()用法及代碼示例
- R語言 lower.tri()用法及代碼示例
- R語言 dim()用法及代碼示例
- R語言 colSums()用法及代碼示例
- R語言 col()用法及代碼示例
- R語言 colMeans()用法及代碼示例
- R語言 det()用法及代碼示例
- R語言 diag()用法及代碼示例
- R語言 apply()用法及代碼示例
- R語言 row()用法及代碼示例
- R語言 upper.tri()用法及代碼示例
- R語言 max.col()用法及代碼示例
- R語言 isSymmetric()用法及代碼示例
- R語言 tr()用法及代碼示例
注:本文由純淨天空篩選整理自nidhi_biet大神的英文原創作品 Find Eigenvalues and Eigenvectors of a Matrix in R Programming – eigen() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
