Java List Mean mean(List numbers)

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

Description

Returns the mean number in the numbers list.

License

Open Source License

Parameter

Parameter Description
numbers the numbers to calculate the mean.

Return

the mean of the numbers.

Declaration

public static double mean(List<Number> numbers) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.List;

public class Main {
    /**/*w w  w  .j  av  a 2  s. c o  m*/
     * Returns the mean number in the numbers list.
     *
     * @param numbers the numbers to calculate the mean.
     * @return the mean of the numbers.
     */
    public static double mean(List<Number> numbers) {
        double sum = sum(numbers);
        return sum / numbers.size();
    }

    /**
     * Returns the sum number in the numbers list.
     *
     * @param numbers the numbers to calculate the sum.
     * @return the sum of the numbers.
     */
    public static double sum(List<Number> numbers) {
        double sum = 0;
        for (Number value : numbers) {
            sum += value.doubleValue();
        }
        return sum;
    }
}

Related

  1. mean(List list)
  2. mean(List vals)
  3. mean(List values)
  4. mean(List values)
  5. mean(List values)
  6. meanAbsolute(List vector)
  7. meanDouble(List list)
  8. meanDoubleList(List list)
  9. normalizeFromMeanAndStdev(List values, double mean, double stdev)