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

doublegetAverage(List numbers)
get Average
double avg = 0;
for (T i : numbers)
    avg += i.doubleValue();
return avg / numbers.size();
intgetAverageColour(List colours)
get Average Colour
int r = 0;
int g = 0;
int b = 0;
int a = 0;
int col;
int count = colours.size();
for (int i = 0; i < count; i++) {
    col = colours.get(i);
...
longgetAverageDuration(List durations)
get Average Duration
long sum = 0;
for (Long l : durations) {
    sum = sum + l;
long avg = 0;
if (durations.size() > 0) {
    avg = (long) (sum / durations.size());
return avg;
longgetAverageInterval(List tapTimestamps, int n)
Calculates the average difference between the last n timestamp intervals of the input array.
long result = 0;
int start = tapTimestamps.size() - (n + 1);
if (start < 0) {
    start = 0;
    n = tapTimestamps.size() - 1;
if (n == 0) {
    return 0;
...
longgetStandardDeviation(List longList, long average, long devByZero)
get Standard Deviation
if (longList == null || longList.isEmpty()) {
    return devByZero;
double sd = 0.0d;
for (long l : longList) {
    sd += Math.pow(l - average, 2);
sd = Math.sqrt(sd / (double) longList.size());
...