Java List Mean getMean(List data)

Here you can find the source of getMean(List data)

Description

get Mean

License

Open Source License

Declaration

public static double getMean(List<Double> data) 

Method Source Code

//package com.java2s;
//License from project: GNU General Public License 

import java.util.List;

public class Main {
    public static double getMean(List<Double> data) {
        // sd is sqrt of sum of (values-mean) squared divided by n - 1 
        // Calculate the mean 
        double mean = 0;
        final int n = data.size();
        if (n < 2) {
            return Double.NaN;
        }/*from   w  w w .j a va 2s  .com*/
        for (int i = 0; i < n; i++) {
            mean += data.get(i);
        }
        mean /= n;
        return mean;
    }
}

Related

  1. calculateStDev(List values, double mean)
  2. computeMean(List fs)
  3. geometricMean(List vals, double replacement)
  4. getHMean(List harray)
  5. getMean(List list)
  6. getStandardDeviation(double meanValue, List values)
  7. getStandardDeviation(List doubles, Double mean)
  8. getStandardDeviationOfMean(List doubles)