@@ 3174-3207 (lines=34) @@ | ||
3171 | * |
|
3172 | * @return float |
|
3173 | */ |
|
3174 | public static function STDEV() |
|
3175 | { |
|
3176 | $aArgs = Functions::flattenArrayIndexed(func_get_args()); |
|
3177 | ||
3178 | // Return value |
|
3179 | $returnValue = null; |
|
3180 | ||
3181 | $aMean = self::AVERAGE($aArgs); |
|
3182 | if (!is_null($aMean)) { |
|
3183 | $aCount = -1; |
|
3184 | foreach ($aArgs as $k => $arg) { |
|
3185 | if ((is_bool($arg)) && |
|
3186 | ((!Functions::isCellValue($k)) || (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE))) { |
|
3187 | $arg = (int) $arg; |
|
3188 | } |
|
3189 | // Is it a numeric value? |
|
3190 | if ((is_numeric($arg)) && (!is_string($arg))) { |
|
3191 | if (is_null($returnValue)) { |
|
3192 | $returnValue = pow(($arg - $aMean), 2); |
|
3193 | } else { |
|
3194 | $returnValue += pow(($arg - $aMean), 2); |
|
3195 | } |
|
3196 | ++$aCount; |
|
3197 | } |
|
3198 | } |
|
3199 | ||
3200 | // Return |
|
3201 | if (($aCount > 0) && ($returnValue >= 0)) { |
|
3202 | return sqrt($returnValue / $aCount); |
|
3203 | } |
|
3204 | } |
|
3205 | ||
3206 | return Functions::DIV0(); |
|
3207 | } |
|
3208 | ||
3209 | /** |
|
3210 | * STDEVA. |
|
@@ 3275-3306 (lines=32) @@ | ||
3272 | * |
|
3273 | * @return float |
|
3274 | */ |
|
3275 | public static function STDEVP() |
|
3276 | { |
|
3277 | $aArgs = Functions::flattenArrayIndexed(func_get_args()); |
|
3278 | ||
3279 | $returnValue = null; |
|
3280 | ||
3281 | $aMean = self::AVERAGE($aArgs); |
|
3282 | if (!is_null($aMean)) { |
|
3283 | $aCount = 0; |
|
3284 | foreach ($aArgs as $k => $arg) { |
|
3285 | if ((is_bool($arg)) && |
|
3286 | ((!Functions::isCellValue($k)) || (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE))) { |
|
3287 | $arg = (int) $arg; |
|
3288 | } |
|
3289 | // Is it a numeric value? |
|
3290 | if ((is_numeric($arg)) && (!is_string($arg))) { |
|
3291 | if (is_null($returnValue)) { |
|
3292 | $returnValue = pow(($arg - $aMean), 2); |
|
3293 | } else { |
|
3294 | $returnValue += pow(($arg - $aMean), 2); |
|
3295 | } |
|
3296 | ++$aCount; |
|
3297 | } |
|
3298 | } |
|
3299 | ||
3300 | if (($aCount > 0) && ($returnValue >= 0)) { |
|
3301 | return sqrt($returnValue / $aCount); |
|
3302 | } |
|
3303 | } |
|
3304 | ||
3305 | return Functions::DIV0(); |
|
3306 | } |
|
3307 | ||
3308 | /** |
|
3309 | * STDEVPA. |