@@ 711-744 (lines=34) @@ | ||
708 | * @param mixed $arg,... Data values |
|
709 | * @return float |
|
710 | */ |
|
711 | public static function AVEDEV() |
|
712 | { |
|
713 | $aArgs = Functions::flattenArrayIndexed(func_get_args()); |
|
714 | ||
715 | // Return value |
|
716 | $returnValue = null; |
|
717 | ||
718 | $aMean = self::AVERAGE($aArgs); |
|
719 | if ($aMean != Functions::DIV0()) { |
|
720 | $aCount = 0; |
|
721 | foreach ($aArgs as $k => $arg) { |
|
722 | if ((is_bool($arg)) && |
|
723 | ((!Functions::isCellValue($k)) || (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE))) { |
|
724 | $arg = (integer) $arg; |
|
725 | } |
|
726 | // Is it a numeric value? |
|
727 | if ((is_numeric($arg)) && (!is_string($arg))) { |
|
728 | if (is_null($returnValue)) { |
|
729 | $returnValue = abs($arg - $aMean); |
|
730 | } else { |
|
731 | $returnValue += abs($arg - $aMean); |
|
732 | } |
|
733 | ++$aCount; |
|
734 | } |
|
735 | } |
|
736 | ||
737 | // Return |
|
738 | if ($aCount == 0) { |
|
739 | return Functions::DIV0(); |
|
740 | } |
|
741 | return $returnValue / $aCount; |
|
742 | } |
|
743 | return Functions::NAN(); |
|
744 | } |
|
745 | ||
746 | ||
747 | /** |
|
@@ 1465-1500 (lines=36) @@ | ||
1462 | * @param mixed $arg,... Data values |
|
1463 | * @return float |
|
1464 | */ |
|
1465 | public static function DEVSQ() |
|
1466 | { |
|
1467 | $aArgs = Functions::flattenArrayIndexed(func_get_args()); |
|
1468 | ||
1469 | // Return value |
|
1470 | $returnValue = null; |
|
1471 | ||
1472 | $aMean = self::AVERAGE($aArgs); |
|
1473 | if ($aMean != Functions::DIV0()) { |
|
1474 | $aCount = -1; |
|
1475 | foreach ($aArgs as $k => $arg) { |
|
1476 | // Is it a numeric value? |
|
1477 | if ((is_bool($arg)) && |
|
1478 | ((!Functions::isCellValue($k)) || |
|
1479 | (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE))) { |
|
1480 | $arg = (integer) $arg; |
|
1481 | } |
|
1482 | if ((is_numeric($arg)) && (!is_string($arg))) { |
|
1483 | if (is_null($returnValue)) { |
|
1484 | $returnValue = pow(($arg - $aMean), 2); |
|
1485 | } else { |
|
1486 | $returnValue += pow(($arg - $aMean), 2); |
|
1487 | } |
|
1488 | ++$aCount; |
|
1489 | } |
|
1490 | } |
|
1491 | ||
1492 | // Return |
|
1493 | if (is_null($returnValue)) { |
|
1494 | return Functions::NAN(); |
|
1495 | } else { |
|
1496 | return $returnValue; |
|
1497 | } |
|
1498 | } |
|
1499 | return self::NA(); |
|
1500 | } |
|
1501 | ||
1502 | ||
1503 | /** |