Here you can find the source of calculateStandardDeviation(List
public static Double calculateStandardDeviation(List<Double> doubleList)
//package com.java2s; //License from project: LGPL import java.util.List; public class Main { public static Double calculateStandardDeviation(List<Double> doubleList) { if (doubleList.size() > 1) { double mean = calculateMeanOfArrayListDouble(doubleList); double sumOfSquaredResiduals = 0; for (double a : doubleList) { double residual = mean - a; sumOfSquaredResiduals += Math.pow(residual, 2); }/*from ww w .j a v a 2s . co m*/ // n-1 observations are redundant return Math.sqrt(sumOfSquaredResiduals / (doubleList.size() - 1)); } else { return Double.NaN; } } public static Double calculateStandardDeviation(List<Double> doubleList, double true_value) { if (doubleList.size() > 1) { double sumOfSquaredResiduals = 0; for (double a : doubleList) { double residual = true_value - a; sumOfSquaredResiduals += Math.pow(residual, 2); } // n-1 observations are redundant return Math.sqrt(sumOfSquaredResiduals / (doubleList.size() - 1)); } else { return Double.NaN; } } public static double calculateMeanOfArrayListDouble(List<Double> dList) { double sum = 0; for (double x : dList) { sum += x; } return sum / dList.size(); } }