Here you can find the source of stdev(Collection
public static double stdev(Collection<Double> values)
//package com.java2s; //License from project: Open Source License import java.util.Collection; public class Main { public static double stdev(Collection<Double> values) { double ret = 0; double mean = average(values); for (Double val : values) ret += Math.pow(val - mean, 2); return Math.sqrt(ret / (values.size() - 1)); }/*ww w . ja v a 2s. c om*/ public static double stdev(double[] values) { double ret = 0; double mean = average(values); for (int i = 0; i < values.length; i++) ret += Math.pow(values[i] - mean, 2); return Math.sqrt(ret / (values.length - 1)); } public static double average(Collection<Double> values) { double ret = 0; for (Double val : values) ret += val; return ret / values.size(); } public static double average(double[] values) { double ret = 0; for (int i = 0; i < values.length; i++) ret += values[i]; return ret / values.length; } }