Implementing PCA/Whitening
From Ufldl
m (Changed typo in ZCA whitening code) |
|||
Line 19: | Line 19: | ||
Finally, you can compute <math>\textstyle x_{\rm rot}</math> and <math>\textstyle \tilde{x}</math> as follows: | Finally, you can compute <math>\textstyle x_{\rm rot}</math> and <math>\textstyle \tilde{x}</math> as follows: | ||
- | xrot = U' * x; | + | xrot = U(:,1:k)' * x; % k is number of eigenvectors to keep |
- | xtilde = U(:,1:k)' * x; | + | xtilde = U(:,1:k)' * x; % which corresponds to the # dimensions after reduction |
+ | % set k = size(x, 1) to keep all the eigenvectors | ||
This gives your PCA representation of the data in terms of <math>\textstyle \tilde{x} \in \Re^k</math>. | This gives your PCA representation of the data in terms of <math>\textstyle \tilde{x} \in \Re^k</math>. |