Implementing PCA/Whitening

From Ufldl

Jump to: navigation, search
Line 7: Line 7:
  x = x - repmat(avg, 1, size(x, 2));
  x = x - repmat(avg, 1, size(x, 2));
-
we need to compute <math>\textstyle \Sigma = \frac{1}{m} \sum_{i=1}^m (x^{(i)})(x^{(i)})^T</math>.  If you're implementing this in Matlab (or even if you're implementing this in C++, Java, etc., but have access to an efficient linear algebra library), doing it as an explicit sum is inefficient. Instead, we can instead compute this in one fell swoop as  
+
Next, we need to compute <math>\textstyle \Sigma = \frac{1}{m} \sum_{i=1}^m (x^{(i)})(x^{(i)})^T</math>.  If you're implementing this in Matlab (or even if you're implementing this in C++, Java, etc., but have access to an efficient linear algebra library), doing it as an explicit sum is inefficient. Instead, we can instead compute this in one fell swoop as  
  sigma = x * x' / size(x, 2);
  sigma = x * x' / size(x, 2);

Revision as of 01:37, 29 April 2011

Personal tools