Java List std getStdDeviation(List numbers)

Here you can find the source of getStdDeviation(List numbers)

Description

get Std Deviation

License

Open Source License

Declaration

public static <T extends Number> double getStdDeviation(List<T> numbers) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.List;

public class Main {
    public static <T extends Number> double getStdDeviation(List<T> numbers) {
        return getStdDeviation(numbers, getAverage(numbers));
    }//from w w  w  .j  a v a  2s . co m

    public static <T extends Number> double getStdDeviation(List<T> numbers, double average) {
        double deviation = 0;
        for (T i : numbers)
            deviation += Math.pow(i.doubleValue() - average, 2);

        return Math.sqrt(deviation / numbers.size());
    }

    public static <T extends Number> double getAverage(List<T> numbers) {
        double avg = 0;
        for (T i : numbers)
            avg += i.doubleValue();

        return avg / numbers.size();
    }
}

Related

  1. calculateStandardDeviation(List doubleList)
  2. getStandardDeviation(List data)
  3. getStandardDeviation(List list)
  4. getStandardDeviation(List values)
  5. standardDeviation(List data)
  6. standardDeviation(List values)
  7. standardDeviation(List list)
  8. standardDeviation(List values, double xbar)