Java Utililty Methods Geometric Mean

List of utility methods to do Geometric Mean

Description

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

Method

doublegeometricMean(double a, double b)
geometric Mean
return Math.pow(a * b, 0.5);
doublegeometricMean(double... values)
geometric Mean
return Math.pow(product(values), 1. / values.length);
doublegeometricMean(double[] nums)
Return the geometric mean of an array of numbers.
double prod = 1.0;
for (double num : nums) {
    prod *= num;
return Math.pow(prod, 1.0 / (double) nums.length);
doublegeometricMean(double[] values)
Calculates the geometric mean The geometric mean is the product of all values in the array to the Nth root, where N is the total number of values in the array.
double geometricMean;
int size = values.length;
double[] logValues = new double[size];
for (int i = 0; i < size; i++) {
    logValues[i] = Math.log(values[i]);
geometricMean = geometricMeanFromLog(logValues);
return geometricMean;
...
doublegeometricMean(final double[] values)
Returns the geometric mean of the entries in the input array.
return (geometricMean(values, null));
floatgeometricMean(float[] xs)
geometric Mean
if (xs == null || xs.length == 0)
    throw new IllegalArgumentException("Input to mean() is an empty array");
float prod = 1.0f;
for (int i = 0; i < xs.length; ++i)
    prod *= xs[i];
return (float) Math.pow((double) prod, 1.0 / xs.length);
doublegeometricMeanFromLog(double[] logValues)
Calculates the geometric mean of log values.
double logArithmeticMean = arithmeticMean(logValues);
double geometricMean = Math.exp(logArithmeticMean);
return geometricMean;