Here you can find the source of mean(final Collection
public static double mean(final Collection<Double> values)
//package com.java2s; //License from project: Open Source License import java.util.Collection; public class Main { /**//from w w w .jav a 2 s .c o m * Calculates the mean of a Collection */ public static double mean(final Collection<Double> values) { return sum(values) / values.size(); } /** * Calculates the sum of an Array */ public static double sum(final double... array) { double sum = 0; for (final double element : array) { sum += element; } return sum; } /** * Calculates the sum of a Collection */ public static double sum(final Iterable<Double> values) { double sum = 0; for (final Double element : values) { sum += element; } return sum; } }