@@ 2990-3021 (lines=32) @@ | ||
2987 | * @param mixed $arg,... Data values |
|
2988 | * @return float |
|
2989 | */ |
|
2990 | public static function STDEV() { |
|
2991 | $aArgs = PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args()); |
|
2992 | ||
2993 | // Return value |
|
2994 | $returnValue = null; |
|
2995 | ||
2996 | $aMean = self::AVERAGE($aArgs); |
|
2997 | if (!is_null($aMean)) { |
|
2998 | $aCount = -1; |
|
2999 | foreach ($aArgs as $k => $arg) { |
|
3000 | if ((is_bool($arg)) && |
|
3001 | ((!PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) { |
|
3002 | $arg = (integer) $arg; |
|
3003 | } |
|
3004 | // Is it a numeric value? |
|
3005 | if ((is_numeric($arg)) && (!is_string($arg))) { |
|
3006 | if (is_null($returnValue)) { |
|
3007 | $returnValue = pow(($arg - $aMean),2); |
|
3008 | } else { |
|
3009 | $returnValue += pow(($arg - $aMean),2); |
|
3010 | } |
|
3011 | ++$aCount; |
|
3012 | } |
|
3013 | } |
|
3014 | ||
3015 | // Return |
|
3016 | if (($aCount > 0) && ($returnValue >= 0)) { |
|
3017 | return sqrt($returnValue / $aCount); |
|
3018 | } |
|
3019 | } |
|
3020 | return PHPExcel_Calculation_Functions::DIV0(); |
|
3021 | } // function STDEV() |
|
3022 | ||
3023 | ||
3024 | /** |
|
@@ 3089-3120 (lines=32) @@ | ||
3086 | * @param mixed $arg,... Data values |
|
3087 | * @return float |
|
3088 | */ |
|
3089 | public static function STDEVP() { |
|
3090 | $aArgs = PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args()); |
|
3091 | ||
3092 | // Return value |
|
3093 | $returnValue = null; |
|
3094 | ||
3095 | $aMean = self::AVERAGE($aArgs); |
|
3096 | if (!is_null($aMean)) { |
|
3097 | $aCount = 0; |
|
3098 | foreach ($aArgs as $k => $arg) { |
|
3099 | if ((is_bool($arg)) && |
|
3100 | ((!PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) { |
|
3101 | $arg = (integer) $arg; |
|
3102 | } |
|
3103 | // Is it a numeric value? |
|
3104 | if ((is_numeric($arg)) && (!is_string($arg))) { |
|
3105 | if (is_null($returnValue)) { |
|
3106 | $returnValue = pow(($arg - $aMean),2); |
|
3107 | } else { |
|
3108 | $returnValue += pow(($arg - $aMean),2); |
|
3109 | } |
|
3110 | ++$aCount; |
|
3111 | } |
|
3112 | } |
|
3113 | ||
3114 | // Return |
|
3115 | if (($aCount > 0) && ($returnValue >= 0)) { |
|
3116 | return sqrt($returnValue / $aCount); |
|
3117 | } |
|
3118 | } |
|
3119 | return PHPExcel_Calculation_Functions::DIV0(); |
|
3120 | } // function STDEVP() |
|
3121 | ||
3122 | ||
3123 | /** |