Here you can find the source of avg(double[] values)
Parameter | Description |
---|---|
values | double array the average is calculated from |
public static double avg(double[] values)
//package com.java2s; //License from project: Open Source License public class Main { /**// www .j a v a2s .c om * Calculates the average over an given array of doubles. * * @param values * double array the average is calculated from * @return average value of the given double array */ public static double avg(double[] values) { double avg = 0; for (double v : values) { avg += v; } return avg / values.length; } /** * Calculates the average over an given array of integers. * * @param values * integer array the average is calculated from * @return average value of the given integer array */ public static double avg(int[] values) { double avg = 0; for (int v : values) { avg += v; } return avg / values.length; } /** * Calculates the average over an given array of longs. * * @param values * long array the average is calculated from * @return average value of the given long array */ public static double avg(long[] values) { double avg = 0; for (long v : values) { avg += v; } return avg / values.length; } }