Java mean mean(double values[])

Here you can find the source of mean(double 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(double values[]) 

Method Source Code

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

public class Main {
    /**//from w ww. jav a2s.  c  om
     * 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;
    }
}

Related

  1. mean(Collection terms)
  2. mean(double a, double b)
  3. mean(double ask, double bid)
  4. mean(Double totalValue, int numValues)
  5. mean(double v1, double v2)
  6. mean(Double[] a)
  7. mean(double[] a)
  8. mean(double[] a)
  9. mean(double[] a)