Question about different results using PCA and SVD

8 ビュー (過去 30 日間)
HpW
HpW 2022 年 8 月 16 日
コメント済み: HpW 2022 年 8 月 16 日
Hello
I'm in the process of larning about SVD and PCA, and have been experimenting by using Matlab
I have a 3D set of points as a nx3 column vector called XYZ_orig
I subtracted the mean from X, Y, and Z and perform SVD and PCA on the data:
cent=[mean(XYZ_orig(:,1)), mean(XYZ_orig(:,2)), mean(XYZ_orig(:,3))];
XYZ = [XYZ_orig(:,1)-cent(1),XYZ_orig(:,2)-cent(2),XYZ_orig(:,3)-cent(3)];
[U,S,V] = svd(XYZ);
[coeff,~,~,~,~,~] = pca(XYZ);
my understanding is the basis vectors/coefficients for SVD in 'V' and PCA in 'coeff' should be the same, however, although the 1st column is always the same, I am finding that the second and third columns are always of different sign with the same coefficients.
V =
0.5926 -0.2694 -0.7591
0.7193 -0.2470 0.6493
-0.3624 -0.9308 0.0474
coeff =
0.5926 0.2694 0.7591
0.7193 0.2470 -0.6493
-0.3624 0.9308 -0.0474
Can someone explain why there is this sign difference for columns 2 and 3?
thanks!
hpw

採用された回答

Steven Lord
Steven Lord 2022 年 8 月 16 日
From the Algorithms section on the pca documentation page: "The pca function imposes a sign convention, forcing the element with the largest magnitude in each column of coefs to be positive. Changing the sign of a coefficient vector does not change its meaning."

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDimensionality Reduction and Feature Extraction についてさらに検索

タグ

製品


リリース

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by