Java List Mean mean(List list)

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

Description

This method returns you the mean value for a List of Doubles

License

BSD License

Parameter

Parameter Description
list a parameter

Declaration

public static Double mean(List<Double> list) 

Method Source Code


//package com.java2s;
/*L/*  ww  w. j  av  a2  s.  c om*/
 *  Copyright SAIC
 *
 *  Distributed under the OSI-approved BSD 3-Clause License.
 *  See http://ncip.github.com/stats-analysis/LICENSE.txt for details.
 */

import java.util.Collections;
import java.util.List;

public class Main {
    /**
     * This method returns you the mean value for a List of Doubles
     * @param list
     * @return
     */
    public static Double mean(List<Double> list) {
        double sum = 0; // sum of all the elements
        if (list == null) {
            list = Collections.emptyList();
        }
        for (Double i : list) {
            sum += i;
        }
        return sum / list.size();
    }
}

Related

  1. mean(double[] list)
  2. mean(final List list)
  3. mean(List data)
  4. mean(List nums, int start, int size)
  5. mean(List data)
  6. mean(List list)
  7. mean(List vals)
  8. mean(List values)
  9. mean(List values)