Here's a multi-valued implementation of some Matlab code for whitening matrices that I got from here .
import numpy as np def whiten(X,fudge=1E-18):
You can also whiten the matrix using SVD:
def svd_whiten(X): U, s, Vt = np.linalg.svd(X, full_matrices=False)
The second method is a bit slower, but probably more numerically stable.
ali_m source share