public static double StdDev ( int [ ] values , double mean ) { double stddev = 0 ; double diff ; int hits ; int total = 0 ; // for all values for ( int i = 0 , n = values . length ; i < n ; i ++ ) { hits = values [ i ] ; diff = ( double ) i - mean ; // accumulate std.dev. stddev += diff * diff * hits ; // accumalate total total += hits ; } return ( total == 0 ) ? 0 : Math . sqrt ( stddev / ( total - 1 ) ) ; }
Calculate standart deviation .