%assumes input matrix has samples as rows
function [n] =normalize(in) 

in = in';
[n d] = size(in);

m =  mean(in);
n = in-repmat(m,n,1);

v = sqrt(var(in));
v = 1./v;
D = diag(v);
n = n*D;
n = n';