Java mean mean(double[] a, int n)

Here you can find the source of mean(double[] a, int n)

Description

Returns the mean.

License

Apache License

Parameter

Parameter Description
a the array.
n the total number of elements.

Return

the mean.

Declaration

public static double mean(double[] a, int n) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**//w  ww . j a v  a  2  s .  c  o  m
     * Returns the mean.
     * 
     * @param a the array.
     * @return the mean.
     */
    public static double mean(double[] a) {
        return mean(a, a.length);
    }

    /**
     * Returns the mean.
     * 
     * @param a the array.
     * @param n the total number of elements.
     * @return the mean.
     */
    public static double mean(double[] a, int n) {
        double avg = 0.0;
        for (double v : a) {
            avg += v;
        }
        return avg / n;
    }
}

Related

  1. mean(double[] a)
  2. mean(double[] a)
  3. mean(double[] a, double[] b)
  4. mean(double[] a, double[] b)
  5. mean(double[] a, int from, int to)
  6. mean(double[] aArray)
  7. mean(double[] an)
  8. mean(double[] arr)
  9. mean(Double[] array)