Java Utililty Methods List Mean

List of utility methods to do List Mean

Description

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

Method

doublecalculateStDev(List values, double mean)
calculate St Dev
int listSize = values.size();
Double sumOfDiffSquared = 0.0;
for (Double value : values) {
    double diffFromMean = value - mean;
    sumOfDiffSquared += ((diffFromMean * diffFromMean) / (listSize - 1));
double variance = sumOfDiffSquared;
return Math.sqrt(variance);
...
doublecomputeMean(List fs)
compute Mean
Double sum = 0.0;
for (Number d : fs)
    sum += d.doubleValue();
return sum / fs.size();
doublegeometricMean(List vals, double replacement)
Return the geometric mean of the absolute values of elements
int numVals = vals.size();
double product = 1.0;
for (int i = 0; i < numVals; i++) {
    Double val = (Double) vals.get(i);
    double dval = (val.isNaN()) ? replacement : val.doubleValue();
    if (dval == 0.0) {
        dval = replacement;
    product *= Math.abs(dval);
return (Math.pow(product, 1.0 / (double) numVals));
doublegetHMean(List harray)
Compute mean for a given set of numbers
Iterator<Number> it = harray.iterator();
double vsum = 0, mean = 0;
int count = 0;
while (it.hasNext()) {
    Number vl = it.next();
    double val = vl.doubleValue();
    vsum += val;
    count++;
...
doublegetMean(List data)
get Mean
double mean = 0;
final int n = data.size();
if (n < 2) {
    return Double.NaN;
for (int i = 0; i < n; i++) {
    mean += data.get(i);
mean /= n;
return mean;
doublegetMean(List list)
get Mean
double sum = 0.0;
for (double value : list) {
    sum += value;
return sum / list.size();
doublegetStandardDeviation(double meanValue, List values)
get Standard Deviation
if (values.isEmpty()) {
    return -1.0;
double sum = 0.0;
for (Double value : values) {
    sum += Math.pow(meanValue - value, 2.0);
return Math.sqrt(sum / (values.size() - 1));
...
DoublegetStandardDeviation(List doubles, Double mean)
get Standard Deviation
double sum = 0;
int i = 0;
for (Double d : doubles) {
    if (d == null)
        continue;
    sum += (d - mean) * (d - mean);
    i++;
return i == 0 ? null : Math.sqrt(sum / i);
doublegetStandardDeviationOfMean(List doubles)
get Standard Deviation Of Mean
return getStandardDeviation(doubles, getMean(doubles));
doublemean(double[] list)
mean
return sum(list) / list.length;