Here you can find the source of mean_Integer(List
Parameter | Description |
---|---|
values | the vector |
public static double mean_Integer(List<Integer> values)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { /**//from w w w .j av a 2 s.co m * Computes average of the elements of the vector. * @param values the vector * @return the average of the elements of the vector */ public static double mean_Integer(List<Integer> values) { return mean(toIntegerArray(values)); } /** * Computes average of the elements of the vector. * @param values the vector * @return the average of the elements of the vector */ public static double mean(double values[]) { double sum = 0; for (double value : values) sum += value; return sum / values.length; } /** * Computes average of the elements of the vector. * @param values the vector * @return the average of the elements of the vector */ public static double mean(int values[]) { double sum = 0; for (int value : values) sum += value; return sum / values.length; } /** * Creates an array of type int[] from a list of instances of class Integer. * @param values the list of instances of class Integer * @return the array of type int[] containing the values from the given list */ public static int[] toIntegerArray(List<Integer> values) { int ret[] = new int[values.size()]; for (int i = 0; i < ret.length; i++) ret[i] = values.get(i); return ret; } }