Here you can find the source of mean(double[] a, int n)
Parameter | Description |
---|---|
a | the array. |
n | the total number of elements. |
public static double mean(double[] a, int n)
//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; } }