Java Mean Calculate mean(ArrayList a)

Here you can find the source of mean(ArrayList a)

Description

mean

License

Open Source License

Declaration

public static <T extends Number> double mean(ArrayList<T> a) 

Method Source Code


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

import java.util.ArrayList;

public class Main {
    public static <T extends Number> double mean(ArrayList<T> a) {
        return sum(a) / a.size();
    }/*w  w w.j  a v a  2 s.c  o m*/

    public static <T extends Number> double sum(ArrayList<T> a) {
        double sum = 0;
        for (int i = 0; i < a.size(); i++)
            sum += a.get(i).doubleValue();
        return sum;
    }
}

Related

  1. computeMean(int val1, int val2, float ratio)
  2. computeMean(int[][] pixels)
  3. computeMeanSquaredError(double[] trueValues, double[] predValues)
  4. computeMeanSquareError(double[] x, double[] y)
  5. mean(ArrayList values)
  6. mean(Double... values)