Here you can find the source of mean(double[] arr)
public static double mean(double[] arr)
//package com.java2s; //License from project: Open Source License public class Main { public static double mean(double[] arr) { if (arr == null || arr.length == 0) return 0; return sum(arr) / arr.length; }//from w w w . j ava 2s . co m public static int sum(int[] arr) { if (arr == null || arr.length == 0) return 0; int l = arr.length; int res = 0; for (int i = 0; i < l; i++) { res += arr[i]; } return res; } public static double sum(double[] arr) { if (arr == null || arr.length == 0) return 0; int l = arr.length; double res = 0; for (int i = 0; i < l; i++) { res += arr[i]; } return res; } }