Java Utililty Methods Array Average

List of utility methods to do Array Average

Description

The list of methods to do Array Average are organized into topic(s).

Method

Doubleaverage(Double sum, Double size)
average
if (Math.abs(size) < 0.0001)
    return 0.0; 
return sum / size;
doubleaverage(double values[])
average
int s = values.length;
if (s == 0)
    return Double.MIN_VALUE;
double avg = 0.0;
for (int i = 0; i < s; i++)
    avg += values[i];
return avg / s;
doubleaverage(double x, double y)
Average two numbers
return (x + y) / 2;
doubleaverage(double x1, double x2)
average
return (x1 + x2) / 2;
doubleaverage(double... args)
average
double total = 0D;
for (double value : args) {
    total += value;
return total / args.length;
doubleaverage(double... vals)
If you think your values will overflow this operation, then roll your own
if (vals == null || vals.length == 0) {
    return 0;
return sum(vals) / vals.length;
doubleaverage(double[] a)
average
return sum(a) / a.length;
doubleaverage(double[] a)
average
return sum(a) / a.length;
Doubleaverage(Double[] arr)
average
return sum(arr) / arr.length;
doubleaverage(double[] array)
Returns the average value of an array.
return array.length == 0 ? 0 : sum(array) / array.length;