Here you can find the source of stddev(int[] values, int start, int length)
public static float[] stddev(int[] values, int start, int length)
//package com.java2s; // under the terms of the GNU Lesser General Public License as published public class Main { /**//w ww .j av a2s.com * Computes the standard deviation of the supplied values. * * @return an array of three values: the mean, variance and standard * deviation, in that order. */ 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) }; } }