Java List Mean meanDoubleList(List list)

Here you can find the source of meanDoubleList(List list)

Description

mean Double List

License

Open Source License

Declaration

public static double meanDoubleList(List<Double> list) 

Method Source Code

//package com.java2s;
/*/*from   w ww.j  a v a  2 s  .  co m*/
 *  Copyright (c) 2008--2014, The University of Sheffield. See the file
 *  COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
 *
 *  This file is part of GATE (see http://gate.ac.uk/), and is free
 *  software, licenced under the GNU Library General Public License,
 *  Version 2, June 1991 (in the distribution as file licence.html,
 *  and also available at http://gate.ac.uk/gate/licence.html).
 *
 *  $Id: Utilities.java 17718 2014-03-20 20:40:06Z adamfunk $
 */

import java.util.List;

public class Main {
    public static double meanDoubleList(List<Double> list) {
        if (list.isEmpty()) {
            return 0.0;
        }
        // implied else
        double total = 0.0;
        for (Double item : list) {
            total += item;
        }
        return total / ((double) list.size());
    }
}

Related

  1. mean(List values)
  2. mean(List values)
  3. mean(List numbers)
  4. meanAbsolute(List vector)
  5. meanDouble(List list)
  6. normalizeFromMeanAndStdev(List values, double mean, double stdev)
  7. standardDeviation(List values, Double mean)