public static float [ ] stddev ( int [ ] values , int start , int length ) { // first we need the mean float mean = 0f ; for ( int ii = start , end = start + length ; ii < end ; ii ++ ) { mean += values [ ii ] ; } mean /= length ; // next we compute the variance float variance = 0f ; for ( int ii = start , end = start + length ; ii < end ; ii ++ ) { float value = values [ ii ] - mean ; variance += value * value ; } variance /= ( length - 1 ) ; // the standard deviation is the square root of the variance return new float [ ] { mean , variance , ( float ) Math . sqrt ( variance ) } ; }
Computes the standard deviation of the supplied values .