Java Utililty Methods List Average

List of utility methods to do List Average

Description

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

Method

NumberaverageValue(List oper)
average Value
double avg = 0.0;
for (int i = 0, j = oper.size(); i < j; i++) {
    avg += oper.get(i).doubleValue();
return avg / oper.size();
longcalculateAverage(final List durations)
calculate Average
long sumNs = 0;
for (final Long value : durations) {
    sumNs += value;
return sumNs / durations.size();
DoublecalculateAverage(List list)
Average of ints in array x.
double sum = 0;
long N = 0;
if (!list.isEmpty()) {
    for (Double z : list) {
        if (z != null && !Double.isNaN(z)) {
            sum += z;
            N++;
    return (double) sum / N;
return Double.NaN;
DoublecomputeAverage(List aList)
compute Average
Double sum = 0.0;
if (aList.size() > 0) {
    for (Iterator<Double> iterator = aList.iterator(); iterator.hasNext();) {
        Double double1 = iterator.next();
        sum += double1;
    return sum / aList.size();
} else {
...
doublegetAverage(int period, List timeline)
average in specified period.
if (period > timeline.size())
    return -1;
double average = 0.0;
for (int i = 0; i < period && i < timeline.size(); i++) {
    double value = timeline.get(i);
    average += value;
average /= period;
...
doublegetAverage(List list)
Gets the average.
Double total = 0.0;
for (Number item : list) {
    total += item.doubleValue();
return total / list.size();
DoublegetAverage(List l)
Computes list average.
Double sumc = 0.0;
for (Double num : l)
    sumc += num;
return sumc / l.size();
doublegetAverage(List values)
get Average
double sum = 0d;
for (Double d : values) {
    sum += d;
return sum / values.size();
DoublegetAverage(List values)
Returns the average of the given values.
Double sum = getSum(values);
return sum / values.size();
doublegetAverage(List values)
get Average
double sum = 0;
for (double d : values)
    sum += d;
return sum / values.size();