This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def whiten(X, method='zca'): | |
""" | |
Whitens the input matrix X using specified whitening method. | |
Inputs: | |
X: Input data matrix with data examples along the first dimension | |
method: Whitening method. Must be one of 'zca', 'zca_cor', 'pca', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''Python library for decorrelating and correlating data | |
Forked from joelouismarino/whiten.py. | |
Also based on R's rdrr.io/cran/whitening/src/R/whiteningMatrix.R, | |
and an SAS blog post: | |
blogs.sas.com/content/iml/2012/02/08/use-the-cholesky- | |
transformation-to-correlate-and-uncorrelate-variables.html | |
''' | |
import numpy as np | |
import scipy.linalg as la |
OlderNewer