Java mean mean_Integer(List values)

Here you can find the source of mean_Integer(List values)

Description

Computes average of the elements of the vector.

License

Open Source License

Parameter

Parameter Description
values the vector

Return

the average of the elements of the vector

Declaration

public static double mean_Integer(List<Integer> values) 

Method Source Code


//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;
    }
}

Related

  1. mean(List a)
  2. mean(List values)
  3. mean(long[] values)
  4. mean(Number[] array)
  5. Mean(Object in)
  6. meanAbortedExecutionTime( double totalExecutionTime, int totalOps, double granuleAbortProb)
  7. meanAndStandardDeviation(final double[] inp, final int startIndex, final int pastEnd)
  8. meanAndVariance(double[] a, boolean useUnbiasedEstimate)
  9. meanArithmetic(LinkedList a)