Fix NaN bug caused by whitening function in large datasets