Question about different results using PCA and SVD

4 visualizaciones (últimos 30 días)
HpW
HpW el 16 de Ag. de 2022
Comentada: HpW el 16 de Ag. de 2022
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

Respuesta aceptada

Steven Lord
Steven Lord el 16 de Ag. de 2022
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."

Más respuestas (0)

Categorías

Más información sobre Dimensionality Reduction and Feature Extraction en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by