Java List Mean calculateStDev(List values, double mean)

Here you can find the source of calculateStDev(List values, double mean)

Description

calculate St Dev

License

Open Source License

Declaration

public static double calculateStDev(List<Double> values, double mean) 

Method Source Code

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

import java.util.List;

public class Main {
    public static double calculateStDev(List<Double> values, double mean) {

        int listSize = values.size();

        Double sumOfDiffSquared = 0.0;
        for (Double value : values) {
            double diffFromMean = value - mean;
            sumOfDiffSquared += ((diffFromMean * diffFromMean) / (listSize - 1));
            // division moved here to avoid sum becoming too big if this
            // doesn't work use incremental formulation

        }//from   w w w  .  j  a  v  a2 s.com
        double variance = sumOfDiffSquared;
        // (listSize - 1);
        // assumes at least 2 members in list.
        return Math.sqrt(variance);
    }
}

Related

  1. computeMean(List fs)
  2. geometricMean(List vals, double replacement)
  3. getHMean(List harray)
  4. getMean(List data)