matlab svd 和 eig 的区别
2016-08-23 00:00
232 查看
Note that eigenvectors are not unique. Multiplying by any constant, including
MATLAB chooses to normalize the eigenvectors to have a norm of 1.0, the sign is arbitrary:
For
Now as you know, SVD and eigendecomposition are related. Below is some code to test this fact. Note that
I get very similar results (ignoring minor floating-point errors):
EDIT:
To get consistent results, one usually adopts a convention of requiring that the first element in each eigenvector be of a certain sign. That way if you get an eigenvector that does not follow this rule, you multiply it by
You can reconstruct A from its eigenvectors only if A is normal (A'*A==A*A'). You can reconstruct A from its singular vectors for any matrix A.
-1(which simply changes the sign), gives another valid eigenvector. This is clear given the definition of an eigenvector:
A·v = λ·v
MATLAB chooses to normalize the eigenvectors to have a norm of 1.0, the sign is arbitrary:
For
eig(A), the eigenvectors are scaled so that the norm of each is 1.0. For
eig(A,B),
eig(A,'nobalance'), and
eig(A,B,flag), the eigenvectors are not normalized
Now as you know, SVD and eigendecomposition are related. Below is some code to test this fact. Note that
svdand
eigreturn results in different order (one sorted high to low, the other in reverse):
% some random matrix A = rand(5); % singular value decomposition [U,S,V] = svd(A); % eigenvectors of A'*A are the same as the right-singular vectors [V2,D2] = eig(A'*A); [D2,ord] = sort(diag(D2), 'descend'); S2 = diag(sqrt(D2)); V2 = V2(:,ord); % eigenvectors of A*A' are the same as the left-singular vectors [U2,D2] = eig(A*A'); [D2,ord] = sort(diag(D2), 'descend'); S3 = diag(sqrt(D2)); U2 = U2(:,ord); % check results A U*S*V' U2*S2*V2'
I get very similar results (ignoring minor floating-point errors):
>> norm(A - U*S*V') ans = 7.5771e-16 >> norm(A - U2*S2*V2') ans = 3.2841e-14
EDIT:
To get consistent results, one usually adopts a convention of requiring that the first element in each eigenvector be of a certain sign. That way if you get an eigenvector that does not follow this rule, you multiply it by
-1to flip the sign...
You can reconstruct A from its eigenvectors only if A is normal (A'*A==A*A'). You can reconstruct A from its singular vectors for any matrix A.
相关文章推荐
- Python库numpy中的svd分解和Matlab中的svd的一点区别
- Matlab与Python中find/where、reshape、eig的区别
- matlab6.5版本和matlab7版本以上的区别
- vc++与matlab混合编程下release与debug的区别
- MATLAB中a./b与a/b的区别以及左除和右除
- matlab saveas 和imwrite的区别
- matlab 中randn randi rand 的用法以及区别
- SVM实现多分类的程序基础工作(一)——安装libsvm以及libsvm和matlab自带的svm的区别
- matlab练习程序(PCA<SVD>)
- matlab中的fix,round,floor,ceil的区别与涵义
- matlab eig sort
- Matlab并行计算中几个变量类型的区别
- matlab中 ndims(a)、size(a)、length(a)的区别<转载>
- matlab中的fix,round,floor,ceil的区别与涵义
- matlab矩阵乘法与矩阵点乘法的规则区别
- rand, randn和randint函数的区别(MATLAB)
- Scilab 语法与 Matlab 的主要区别
- matlab xcorr与cov的区别
- matlab中取模(mod)与取余(rem)的区别
- matlab中 ndims(a)、size(a)、length(a)的区别<转载>