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

ListaddAverage(List list, int InColumn1, int InColumn2, int resultColumn)
InColumn1 / InColumn2 = resultColumn.
for (Object[] objects : list) {
    double div = Double.valueOf(objects[InColumn1].toString());
    double div2 = Double.valueOf(objects[InColumn2].toString());
    if (div2 != 0) {
        objects[resultColumn] = div / div2;
return list;
...
doubleaverage(final List vals, final int maxI)
average
long sum = 0L;
int i = 0;
for (long x : vals) {
    if (i > maxI)
        break;
    sum += x;
    i++;
return (1.0 * sum) / i;
Doubleaverage(List collected)
average
Double result = null;
double allAdded = 0;
int numNulls = 0;
for (Iterator iterator = collected.iterator(); iterator.hasNext();) {
    Object obj = iterator.next();
    Number value = (Number) obj;
    if (value != null) {
        allAdded += value.doubleValue();
...
doubleaverage(List arr)
average
double sum = 0.0d;
int count = 0;
for (int i = 0; i < arr.size(); i++) {
    if (!Double.isNaN(arr.get(i))) {
        sum += arr.get(i);
        count++;
return sum / ((double) count);
doubleaverage(List list)
average
return sum(list) / list.size();
doubleaverage(List numbers)
average
double sum = 0;
for (Double number : numbers)
    sum += number;
return sum / numbers.size();
doubleaverage(List observations)
average
double total = 0.0;
for (double d : observations) {
    total += d;
return total / observations.size();
doubleaverage(List collection)
average
if (collection == null || collection.size() == 0)
    return 9;
if (collection.size() == 1)
    return collection.get(0);
double average = collection.get(0);
for (int i = 1; i < collection.size(); i++)
    average = i * (average + collection.get(i).doubleValue() / i) / (i + 1);
return average;
...
doubleaverageDouble(final List values)
average Double
final double size = values.size();
double avg = 0;
for (final double v : values)
    avg += v / size;
return avg;
doubleaverageLog(List logList)
average Log
if (logList.size() == 1)
    return logList.get(0);
double[] logs = new double[logList.size()];
for (int i = 0; i < logs.length; i++) {
    logs[i] = logList.get(i);
return averageLog(logs);