Here you can find the source of computeStddev(float[] array, float mean)
Parameter | Description |
---|---|
array | the array |
mean | the mean value of the array |
public static float computeStddev(float[] array, float mean)
//package com.java2s; /*/*from w w w.j av a 2 s.co m*/ * 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 float computeStddev(float[] array, float mean) { float stddev = 0; for (int i = 0; i < array.length; i++) { stddev += Math.pow(array[i] - mean, 2); } return (float) Math.sqrt(stddev / array.length); } public static float computeStddev(float[] array, float mean, int start, int end) { float stddev = 0; for (int i = start; i < end; i++) { stddev += Math.pow(array[i] - mean, 2); } return (float) Math.sqrt(stddev / (end - start)); } /** * calls Math.pow for each element of the array * @param array * @param exp the exponent. * @return reference to the input array */ public static float[] pow(float[] array, float exp) { for (int i = 0; i < array.length; i++) { array[i] = (float) Math.pow((double) array[i], exp); } return array; } }