public static void standardize ( double [ ] x ) { double mu = mean ( x ) ; double sigma = sd ( x ) ; if ( isZero ( sigma ) ) { logger . warn ( "array has variance of 0." ) ; return ; } for ( int i = 0 ; i < x . length ; i ++ ) { x [ i ] = ( x [ i ] - mu ) / sigma ; } }
Standardizes an array to mean 0 and variance 1 .