Here you can find the source of calculateStDev(List
public static double calculateStDev(List<Double> values, double mean)
//package com.java2s; //License from project: Open Source License import java.util.List; public class Main { public static double calculateStDev(List<Double> values, double mean) { int listSize = values.size(); Double sumOfDiffSquared = 0.0; for (Double value : values) { double diffFromMean = value - mean; sumOfDiffSquared += ((diffFromMean * diffFromMean) / (listSize - 1)); // division moved here to avoid sum becoming too big if this // doesn't work use incremental formulation }//from w w w . j a v a2 s.com double variance = sumOfDiffSquared; // (listSize - 1); // assumes at least 2 members in list. return Math.sqrt(variance); } }