Here you can find the source of getMean(List
public static double getMean(List<Double> data)
//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; } }