Java List std std(List iNumbers)

Here you can find the source of std(List iNumbers)

Description

std

License

Open Source License

Parameter

Parameter Description
iNumbers - doubles

Return

the standard deviation

Declaration

public static double std(List<Double> iNumbers) 

Method Source Code

//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();
    }
}

Related

  1. standardDeviation(List data)
  2. standardDeviation(List values)
  3. standardDeviation(List list)
  4. standardDeviation(List values, double xbar)
  5. standardDeviationDouble(List list, boolean populationStandardDeviation)
  6. std(List vector, Double avg)
  7. stdDev(List nums)
  8. stddev(List observations)
  9. stDev(final List list)