@@ 708-743 (lines=36) @@ | ||
705 | * @param mixed $arg,... Data values |
|
706 | * @return float |
|
707 | */ |
|
708 | public static function AVEDEV() |
|
709 | { |
|
710 | $aArgs = Functions::flattenArrayIndexed(func_get_args()); |
|
711 | ||
712 | // Return value |
|
713 | $returnValue = null; |
|
714 | ||
715 | $aMean = self::AVERAGE($aArgs); |
|
716 | if ($aMean != Functions::DIV0()) { |
|
717 | $aCount = 0; |
|
718 | foreach ($aArgs as $k => $arg) { |
|
719 | if ((is_bool($arg)) && |
|
720 | ((!Functions::isCellValue($k)) || (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE))) { |
|
721 | $arg = (integer) $arg; |
|
722 | } |
|
723 | // Is it a numeric value? |
|
724 | if ((is_numeric($arg)) && (!is_string($arg))) { |
|
725 | if (is_null($returnValue)) { |
|
726 | $returnValue = abs($arg - $aMean); |
|
727 | } else { |
|
728 | $returnValue += abs($arg - $aMean); |
|
729 | } |
|
730 | ++$aCount; |
|
731 | } |
|
732 | } |
|
733 | ||
734 | // Return |
|
735 | if ($aCount == 0) { |
|
736 | return Functions::DIV0(); |
|
737 | } |
|
738 | ||
739 | return $returnValue / $aCount; |
|
740 | } |
|
741 | ||
742 | return Functions::NAN(); |
|
743 | } |
|
744 | ||
745 | /** |
|
746 | * AVERAGE |
|
@@ 1448-1484 (lines=37) @@ | ||
1445 | * @param mixed $arg,... Data values |
|
1446 | * @return float |
|
1447 | */ |
|
1448 | public static function DEVSQ() |
|
1449 | { |
|
1450 | $aArgs = Functions::flattenArrayIndexed(func_get_args()); |
|
1451 | ||
1452 | // Return value |
|
1453 | $returnValue = null; |
|
1454 | ||
1455 | $aMean = self::AVERAGE($aArgs); |
|
1456 | if ($aMean != Functions::DIV0()) { |
|
1457 | $aCount = -1; |
|
1458 | foreach ($aArgs as $k => $arg) { |
|
1459 | // Is it a numeric value? |
|
1460 | if ((is_bool($arg)) && |
|
1461 | ((!Functions::isCellValue($k)) || |
|
1462 | (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE))) { |
|
1463 | $arg = (integer) $arg; |
|
1464 | } |
|
1465 | if ((is_numeric($arg)) && (!is_string($arg))) { |
|
1466 | if (is_null($returnValue)) { |
|
1467 | $returnValue = pow(($arg - $aMean), 2); |
|
1468 | } else { |
|
1469 | $returnValue += pow(($arg - $aMean), 2); |
|
1470 | } |
|
1471 | ++$aCount; |
|
1472 | } |
|
1473 | } |
|
1474 | ||
1475 | // Return |
|
1476 | if (is_null($returnValue)) { |
|
1477 | return Functions::NAN(); |
|
1478 | } else { |
|
1479 | return $returnValue; |
|
1480 | } |
|
1481 | } |
|
1482 | ||
1483 | return self::NA(); |
|
1484 | } |
|
1485 | ||
1486 | /** |
|
1487 | * EXPONDIST |