Here you can find the source of geometricMeanFromLog(double[] logValues)
Parameter | Description |
---|---|
logValues | array of values in logarithmic form |
public static double geometricMeanFromLog(double[] logValues)
//package com.java2s; /*/*from ww w. ja v a 2 s. c o m*/ * Copyright 2016 Roche NimbleGen Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { /** * Calculates the geometric mean of log values. * * The geometric mean of logarithmic values is simply the arithmethic mean converted to non-logarithmic values (exponentiated) * * * @param logValues * array of values in logarithmic form * @return geometric mean */ public static double geometricMeanFromLog(double[] logValues) { double logArithmeticMean = arithmeticMean(logValues); double geometricMean = Math.exp(logArithmeticMean); return geometricMean; } /** * calculate the arithmetic mean * * The arithmetic mean is the sum of all values in the array divided by the total number of values in the array. * * @param values * source of data for mean calculation * @return arithmetic mean */ public static double arithmeticMean(double[] values) { double arithmeticMean; int size = values.length; double sum = summation(values); arithmeticMean = sum / size; return arithmeticMean; } /** * @param values * source of data for summation calculation * @return the sum of all values within the array */ public static double summation(double[] values) { double sum = 0.0; int size = values.length; for (int i = 0; i < size; i++) { sum += values[i]; } return sum; } }