# HG changeset patch
# User James Bergstra <bergstrj@iro.umontreal.ca>
# Date 1289516885 18000
# Node ID f81b3b6f969800412284b122e2421f71e960b3d6
# Parent  5db730bb0e8e5f9fffee4801b6a96c8635afd3f2
corrected use of epsilons in pca

diff -r 5db730bb0e8e -r f81b3b6f9698 pylearn/preprocessing/pca.py
--- a/pylearn/preprocessing/pca.py	Thu Nov 11 17:53:13 2010 -0500
+++ b/pylearn/preprocessing/pca.py	Thu Nov 11 18:08:05 2010 -0500
@@ -94,7 +94,7 @@
             max_energy_fraction=max_energy_fraction), centered_X
 
 
-def pca_whiten((eigvals, eigvecs), centered_X,eps=1e-8):
+def pca_whiten((eigvals, eigvecs), centered_X,eps=1e-14):
     """
     Return the projection of X onto it's principle components.  
     
@@ -106,17 +106,17 @@
 
     """
     pca_of_X = numpy.dot(centered_X, eigvecs)
-    pca_of_X /= numpy.sqrt(eigvals)+eps
+    pca_of_X /= numpy.sqrt(eigvals+eps)
     return pca_of_X
 
-def pca_whiten_inverse((eigvals, eigvecs), whitened_X, eps=1e-8):
+def pca_whiten_inverse((eigvals, eigvecs), whitened_X, eps=1e-14):
     """
     Return an approximate inverse of the `pca_whiten` transform.
 
     The inverse is not perfect because pca_whitening discards the least-significant components
     of the data.
     """
-    return numpy.dot(whitened_X * (numpy.sqrt(eigvals)+eps), eigvecs.T)
+    return numpy.dot(whitened_X * (numpy.sqrt(eigvals+eps)), eigvecs.T)
 
 def zca_whiten((eigvals, eigvecs), centered_X):
     """Return the PCA of X but rotated back into the original vector space.