@@ 729-764 (lines=36) @@ | ||
726 | * |
|
727 | * @return float |
|
728 | */ |
|
729 | public static function AVEDEV(...$args) |
|
730 | { |
|
731 | $aArgs = Functions::flattenArrayIndexed($args); |
|
732 | ||
733 | // Return value |
|
734 | $returnValue = null; |
|
735 | ||
736 | $aMean = self::AVERAGE($aArgs); |
|
737 | if ($aMean != Functions::DIV0()) { |
|
738 | $aCount = 0; |
|
739 | foreach ($aArgs as $k => $arg) { |
|
740 | if ((is_bool($arg)) && |
|
741 | ((!Functions::isCellValue($k)) || (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE))) { |
|
742 | $arg = (int) $arg; |
|
743 | } |
|
744 | // Is it a numeric value? |
|
745 | if ((is_numeric($arg)) && (!is_string($arg))) { |
|
746 | if (is_null($returnValue)) { |
|
747 | $returnValue = abs($arg - $aMean); |
|
748 | } else { |
|
749 | $returnValue += abs($arg - $aMean); |
|
750 | } |
|
751 | ++$aCount; |
|
752 | } |
|
753 | } |
|
754 | ||
755 | // Return |
|
756 | if ($aCount == 0) { |
|
757 | return Functions::DIV0(); |
|
758 | } |
|
759 | ||
760 | return $returnValue / $aCount; |
|
761 | } |
|
762 | ||
763 | return Functions::NAN(); |
|
764 | } |
|
765 | ||
766 | /** |
|
767 | * AVERAGE. |
|
@@ 1500-1536 (lines=37) @@ | ||
1497 | * |
|
1498 | * @return float |
|
1499 | */ |
|
1500 | public static function DEVSQ(...$args) |
|
1501 | { |
|
1502 | $aArgs = Functions::flattenArrayIndexed($args); |
|
1503 | ||
1504 | // Return value |
|
1505 | $returnValue = null; |
|
1506 | ||
1507 | $aMean = self::AVERAGE($aArgs); |
|
1508 | if ($aMean != Functions::DIV0()) { |
|
1509 | $aCount = -1; |
|
1510 | foreach ($aArgs as $k => $arg) { |
|
1511 | // Is it a numeric value? |
|
1512 | if ((is_bool($arg)) && |
|
1513 | ((!Functions::isCellValue($k)) || |
|
1514 | (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE))) { |
|
1515 | $arg = (int) $arg; |
|
1516 | } |
|
1517 | if ((is_numeric($arg)) && (!is_string($arg))) { |
|
1518 | if (is_null($returnValue)) { |
|
1519 | $returnValue = pow(($arg - $aMean), 2); |
|
1520 | } else { |
|
1521 | $returnValue += pow(($arg - $aMean), 2); |
|
1522 | } |
|
1523 | ++$aCount; |
|
1524 | } |
|
1525 | } |
|
1526 | ||
1527 | // Return |
|
1528 | if (is_null($returnValue)) { |
|
1529 | return Functions::NAN(); |
|
1530 | } |
|
1531 | ||
1532 | return $returnValue; |
|
1533 | } |
|
1534 | ||
1535 | return self::NA(); |
|
1536 | } |
|
1537 | ||
1538 | /** |
|
1539 | * EXPONDIST. |