Question about different results using PCA and SVD

3 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Dimensionality 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