Here you can find the source of stddev(double[] a)
Parameter | Description |
---|---|
a | the array |
public static double stddev(double[] a)
//package com.java2s; public class Main { /**//from ww w. j a va 2 s .com * Computes the standard deviation of an array * @param a the array * @return the standard deviation */ public static double stddev(double[] a) { double std = 0; double ave = mean(a); for (double d : a) std += (d - ave) * (d - ave); return Math.sqrt(std / (double) a.length); } /** * computes the mean of a double array * @param a the array * @return the mean */ public static double mean(double[] a) { double sum = 0; for (int i = 0; i < a.length; i++) { sum += a[i]; } return sum / (double) a.length; } }