Here you can find the source of calcStdDeviation(double[] population)
public static double calcStdDeviation(double[] population)
//package com.java2s; //License from project: Apache License public class Main { public static double calcStdDeviation(double[] population) { return Math.sqrt(calcVariance(population)); }/*from w w w .ja v a2 s. c o m*/ public static double calcVariance(double[] population) { long n = 0; double mean = 0; double s = 0.0; for (double x : population) { n++; double delta = x - mean; mean += delta / n; s += delta * (x - mean); } //if you want to calculate std deviation //of a sample change this to (s/(n-1)) return (s / n); } public static double calcVariance(double[] values, double mean) { double squares = 0D; for (double value : values) { squares += Math.pow((value - mean), 2); } return squares / (double) values.length; } }