| @@ 700-732 (lines=33) @@ | ||
| 697 | * @param mixed $arg,... Data values |
|
| 698 | * @return float |
|
| 699 | */ |
|
| 700 | public static function AVEDEV() { |
|
| 701 | $aArgs = PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args()); |
|
| 702 | ||
| 703 | // Return value |
|
| 704 | $returnValue = null; |
|
| 705 | ||
| 706 | $aMean = self::AVERAGE($aArgs); |
|
| 707 | if ($aMean != PHPExcel_Calculation_Functions::DIV0()) { |
|
| 708 | $aCount = 0; |
|
| 709 | foreach ($aArgs as $k => $arg) { |
|
| 710 | if ((is_bool($arg)) && |
|
| 711 | ((!PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) { |
|
| 712 | $arg = (integer) $arg; |
|
| 713 | } |
|
| 714 | // Is it a numeric value? |
|
| 715 | if ((is_numeric($arg)) && (!is_string($arg))) { |
|
| 716 | if (is_null($returnValue)) { |
|
| 717 | $returnValue = abs($arg - $aMean); |
|
| 718 | } else { |
|
| 719 | $returnValue += abs($arg - $aMean); |
|
| 720 | } |
|
| 721 | ++$aCount; |
|
| 722 | } |
|
| 723 | } |
|
| 724 | ||
| 725 | // Return |
|
| 726 | if ($aCount == 0) { |
|
| 727 | return PHPExcel_Calculation_Functions::DIV0(); |
|
| 728 | } |
|
| 729 | return $returnValue / $aCount; |
|
| 730 | } |
|
| 731 | return PHPExcel_Calculation_Functions::NaN(); |
|
| 732 | } // function AVEDEV() |
|
| 733 | ||
| 734 | ||
| 735 | /** |
|
| @@ 1431-1464 (lines=34) @@ | ||
| 1428 | * @param mixed $arg,... Data values |
|
| 1429 | * @return float |
|
| 1430 | */ |
|
| 1431 | public static function DEVSQ() { |
|
| 1432 | $aArgs = PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args()); |
|
| 1433 | ||
| 1434 | // Return value |
|
| 1435 | $returnValue = null; |
|
| 1436 | ||
| 1437 | $aMean = self::AVERAGE($aArgs); |
|
| 1438 | if ($aMean != PHPExcel_Calculation_Functions::DIV0()) { |
|
| 1439 | $aCount = -1; |
|
| 1440 | foreach ($aArgs as $k => $arg) { |
|
| 1441 | // Is it a numeric value? |
|
| 1442 | if ((is_bool($arg)) && |
|
| 1443 | ((!PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) { |
|
| 1444 | $arg = (integer) $arg; |
|
| 1445 | } |
|
| 1446 | if ((is_numeric($arg)) && (!is_string($arg))) { |
|
| 1447 | if (is_null($returnValue)) { |
|
| 1448 | $returnValue = pow(($arg - $aMean),2); |
|
| 1449 | } else { |
|
| 1450 | $returnValue += pow(($arg - $aMean),2); |
|
| 1451 | } |
|
| 1452 | ++$aCount; |
|
| 1453 | } |
|
| 1454 | } |
|
| 1455 | ||
| 1456 | // Return |
|
| 1457 | if (is_null($returnValue)) { |
|
| 1458 | return PHPExcel_Calculation_Functions::NaN(); |
|
| 1459 | } else { |
|
| 1460 | return $returnValue; |
|
| 1461 | } |
|
| 1462 | } |
|
| 1463 | return self::NA(); |
|
| 1464 | } // function DEVSQ() |
|
| 1465 | ||
| 1466 | ||
| 1467 | /** |
|