Here you can find the source of stddev(double[] observations)
public static double stddev(double[] observations)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static double stddev(double[] observations) { return Math.sqrt(variance(observations)); }/*from w ww . j av a 2 s. c om*/ public static double variance(List<Double> observations) { double mean = average(observations); double varSum = 0.0; for (double d : observations) { varSum += (d - mean) * (d - mean); } return varSum / observations.size(); } public static double variance(double[] observations) { double mean = average(observations); double varSum = 0.0; for (double d : observations) { varSum += (d - mean) * (d - mean); } // use bessel's correction return varSum / (observations.length - 1); } public static double average(List<Double> observations) { double total = 0.0; for (double d : observations) { total += d; } return total / observations.size(); } public static double average(double[] data) { double total = 0.0; for (double d : data) { total += d; } return total / data.length; } }