Here you can find the source of mean(double[] v)
public static double mean(double[] v)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w w w. j a va 2 s . c o m * Computes the mean. */ public static double mean(double[] v) { if (v.length == 0) throw new IllegalArgumentException("Nothing to compute! The array must have at least one element."); return (mass(v) / (double) v.length); } /** * Computes the mean. */ public static double mean(int[] v) { if (v.length == 0) throw new IllegalArgumentException("Nothing to compute! The array must have at least one element."); return (mass(v) / (double) v.length); } /** * Returns the sum of the elements of the array. */ public static double mass(double[] v) { double somme = 0.0; for (int k = 0; k < v.length; k++) { somme += v[k]; } return (somme); } /** * Returns the sum of the elements of the array. */ public static int mass(int[] v) { int somme = 0; for (int k = 0; k < v.length; k++) { somme += v[k]; } return (somme); } }