public static function PHPExcel_Calculation_Statistical::HARMEAN in Loft Data Grids 7.2
Same name and namespace in other branches
- 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Statistical.php \PHPExcel_Calculation_Statistical::HARMEAN()
* HARMEAN * * Returns the harmonic mean of a data set. The harmonic mean is the reciprocal of the * arithmetic mean of reciprocals. * * Excel Function: * HARMEAN(value1[,value2[, ...]]) * * @access public * @category Statistical Functions *
Parameters
mixed $arg,... Data values: * @return float
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Calculation/ Statistical.php, line 1768
Class
- PHPExcel_Calculation_Statistical
- PHPExcel_Calculation_Statistical
Code
public static function HARMEAN() {
// Return value
$returnValue = PHPExcel_Calculation_Functions::NA();
// Loop through arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
if (self::MIN($aArgs) < 0) {
return PHPExcel_Calculation_Functions::NaN();
}
$aCount = 0;
foreach ($aArgs as $arg) {
// Is it a numeric value?
if (is_numeric($arg) && !is_string($arg)) {
if ($arg <= 0) {
return PHPExcel_Calculation_Functions::NaN();
}
if (is_null($returnValue)) {
$returnValue = 1 / $arg;
}
else {
$returnValue += 1 / $arg;
}
++$aCount;
}
}
// Return
if ($aCount > 0) {
return 1 / ($returnValue / $aCount);
}
else {
return $returnValue;
}
}