You are here

public static function PHPExcel_Calculation_Statistical::GEOMEAN in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Statistical.php \PHPExcel_Calculation_Statistical::GEOMEAN()

* GEOMEAN * * Returns the geometric mean of an array or range of positive data. For example, you * can use GEOMEAN to calculate average growth rate given compound interest with * variable rates. * * Excel Function: * GEOMEAN(value1[,value2[, ...]]) * * @access public * @category Statistical Functions *

Parameters

mixed $arg,... Data values: * @return float

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Statistical.php, line 1709

Class

PHPExcel_Calculation_Statistical
PHPExcel_Calculation_Statistical

Code

public static function GEOMEAN() {
  $aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
  $aMean = PHPExcel_Calculation_MathTrig::PRODUCT($aArgs);
  if (is_numeric($aMean) && $aMean > 0) {
    $aCount = self::COUNT($aArgs);
    if (self::MIN($aArgs) > 0) {
      return pow($aMean, 1 / $aCount);
    }
  }
  return PHPExcel_Calculation_Functions::NaN();
}