Here you can find the source of mean(double[] a)
Parameter | Description |
---|---|
a | The array to calculate the average for. |
public static double mean(double[] a)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w w w . j av a2 s. c o m*/ * @param a The array to calculate the average for. * @return The average over all elements in the array. */ public static double mean(double[] a) { return sum(a) / a.length; } /** * @param a The array to sum. * @return The sum over all elements in the array. */ public static double sum(double[] a) { double sum = 0; for (int i = 0; i < a.length; i++) sum += a[i]; return sum; } /** * @param a The array to sum. * @return The sum over all elements in the array. */ public static long sum(int[] a) { long sum = 0; for (int i = 0; i < a.length; i++) sum += a[i]; return sum; } }