private static Stats calcStats ( List < Double > nums ) { double sum = 0.0 , mean = 0.0 , variance = 0.0 , stdDev = 0.0 ; for ( Double d : nums ) { sum += d . doubleValue ( ) ; } if ( nums . size ( ) > 0 ) { mean = sum / nums . size ( ) ; } sum = 0.0 ; for ( Double d : nums ) { sum += ( d . doubleValue ( ) - mean ) * ( d . doubleValue ( ) - mean ) ; } if ( nums . size ( ) > 0 ) { variance = sum / nums . size ( ) ; } stdDev = Math . sqrt ( variance ) ; return new Stats ( mean , variance , stdDev ) ; }
Calculates mean variance standard deviation for a set of numbers