Here you can find the source of computeStddev(double[] array, double mean)
Parameter | Description |
---|---|
array | the array |
mean | the mean value of the array |
public static double computeStddev(double[] array, double mean)
//package com.java2s; /*/*from www . j a v a 2 s .c om*/ * Copyright (C) 2010-2014 Andreas Maier * CONRAD is developed as an Open Source project under the GNU General Public License (GPL). */ public class Main { /** * Computes the standard deviation given an array and its mean value * @param array the array * @param mean the mean value of the array * @return the standard deviation */ public static double computeStddev(double[] array, double mean) { double stddev = 0; for (int i = 0; i < array.length; i++) { stddev += Math.pow(array[i] - mean, 2); } return Math.sqrt(stddev / array.length); } /** * calls Math.pow for each element of the array * @param array * @param exp the exponent. * @return reference to the input array */ public static double[] pow(double[] array, double exp) { for (int i = 0; i < array.length; i++) { array[i] = Math.pow(array[i], exp); } return array; } }