Java Geometric Mean geometricMean(float[] xs)

Here you can find the source of geometricMean(float[] xs)

Description

geometric Mean

License

Apache License

Declaration

public static float geometricMean(float[] xs) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static float geometricMean(float[] xs) {
        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];//from  w w  w .j a  v a  2  s . c  o m

        return (float) Math.pow((double) prod, 1.0 / xs.length);
    }
}

Related

  1. geometricMean(double a, double b)
  2. geometricMean(double... values)
  3. geometricMean(double[] nums)
  4. geometricMean(double[] values)
  5. geometricMean(final double[] values)
  6. geometricMeanFromLog(double[] logValues)