Skip to content

Instantly share code, notes, and snippets.

View maurotoro's full-sized avatar

Mauricio Alejandro Toro Espejo maurotoro

  • Lisbon, Portugal
View GitHub Profile
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',
@cwindolf
cwindolf / whiten.py
Last active July 13, 2021 15:30 — forked from joelouismarino/whiten.py
Python library for whitening and coloring data
'''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