Here you can find the source of avg(double[] values)
public static double avg(double[] values)
//package com.java2s; //License from project: Apache License public class Main { public static double avg(double[] values) { if (values.length > 0) { return sum(values) / values.length; } else {//from ww w. j a v a2 s . co m return 0.0; } } public static double sum(double[] values) { double sum = 0.0; for (int i = 0; i < values.length; i++) { sum += values[i]; } return sum; } }