Here you can find the source of std(List
Parameter | Description |
---|---|
iNumbers | - doubles |
public static double std(List<Double> iNumbers)
//package com.java2s; //License from project: Open Source License import java.util.List; public class Main { /**//from ww w. ja v a 2 s .c om * * @param iNumbers - doubles * @return the standard deviation */ public static double std(List<Double> iNumbers) { double result = 0; double mu = average(iNumbers); for (Double number : iNumbers) result += Math.pow(number - mu, 2); result /= iNumbers.size(); return Math.sqrt(result); } /** * * @param iNumbers - doubles * @param mu - the average * @return the standard deviation */ public static double std(List<Double> iNumbers, double mu) { double result = 0; for (Double number : iNumbers) result += Math.pow(number - mu, 2); result /= iNumbers.size(); return Math.sqrt(result); } /** * * @param numbers - doubles * @return their average */ public static double average(List<Double> numbers) { double sum = 0; for (Double number : numbers) sum += number; return sum / numbers.size(); } }