Here you can find the source of mean(Collection
Parameter | Description |
---|---|
data | a parameter |
public static Double mean(Collection<Double> data)
//package com.java2s; /******************************************************************************* * Copyright (c) 2009, 2013, 2014 Matthew Purver, Queen Mary University of London. * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Public License v3.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/gpl.html/*from www . ja va 2 s . c o m*/ ******************************************************************************/ import java.util.Collection; public class Main { /** * @param data * @return the mean */ public static Double mean(Collection<Double> data) { return (sum(data) / (double) data.size()); } /** * @param data * @return the mean */ public static double mean(double[] data) { return (sum(data) / (double) data.length); } /** * @param data * @return the sum */ public static Double sum(Collection<Double> data) { Double sum = 0.0; for (Double datum : data) { sum += datum; } return sum; } /** * @param data * @return the sum */ public static double sum(double[] data) { double sum = 0.0; for (double datum : data) { sum += datum; } return sum; } }