1

I am performing a PCA analysis in Matlab on a $110\times 7$ dataset using some custom code. I am checking my code against Matlab's princomp and my eigenvectors are the same except that the 3rd and the 7th column are of the opposite sign.

What does that mean? And why does this happen?

My code is:

mu = mean(data);
data = bsxfun(@minus,data,mu);
sigma = transpose(data) * data / size(data, 1);
[eigenvectors, eigenvalues]=eig(sigma);
eigenvalues=diag(eigenvalues)
[ev index]=sort(eigenvalues,'descend');
eigenvectors=eigenvectors(:,index);
pc = data*eigenvectors';
amoeba
  • 104,745
  • 1
    a) nothing b) the PCA doesn't change if you multiply any of the ev's by -1 ( u'X'Xu is the same for u and -u) – user603 Mar 30 '13 at 13:17
  • 1
    To fill out user603's answer, if you imagine the eigenvectors as new axes, then the difference in sign is only about whether you read them from left to right or from right to left - they're still running along the same line. – conjectures Mar 30 '13 at 15:14

0 Answers0