The working definition of sym
is:
from scipy.linalg import sqrtm, inv
def sym(w):
return w.dot(inv(sqrtm(w.T.dot(w))))
This is because raising a numpy matrix to the power of -.5 is not equivalent to taking the matrix square root and then inverting it, which is what the formula requires.