@@ 3070-3102 (lines=33) @@ | ||
3067 | * @param mixed $arg,... Data values |
|
3068 | * @return float |
|
3069 | */ |
|
3070 | public static function STDEV() |
|
3071 | { |
|
3072 | $aArgs = Functions::flattenArrayIndexed(func_get_args()); |
|
3073 | ||
3074 | // Return value |
|
3075 | $returnValue = null; |
|
3076 | ||
3077 | $aMean = self::AVERAGE($aArgs); |
|
3078 | if (!is_null($aMean)) { |
|
3079 | $aCount = -1; |
|
3080 | foreach ($aArgs as $k => $arg) { |
|
3081 | if ((is_bool($arg)) && |
|
3082 | ((!Functions::isCellValue($k)) || (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE))) { |
|
3083 | $arg = (integer) $arg; |
|
3084 | } |
|
3085 | // Is it a numeric value? |
|
3086 | if ((is_numeric($arg)) && (!is_string($arg))) { |
|
3087 | if (is_null($returnValue)) { |
|
3088 | $returnValue = pow(($arg - $aMean), 2); |
|
3089 | } else { |
|
3090 | $returnValue += pow(($arg - $aMean), 2); |
|
3091 | } |
|
3092 | ++$aCount; |
|
3093 | } |
|
3094 | } |
|
3095 | ||
3096 | // Return |
|
3097 | if (($aCount > 0) && ($returnValue >= 0)) { |
|
3098 | return sqrt($returnValue / $aCount); |
|
3099 | } |
|
3100 | } |
|
3101 | return Functions::DIV0(); |
|
3102 | } |
|
3103 | ||
3104 | ||
3105 | /** |
|
@@ 3169-3199 (lines=31) @@ | ||
3166 | * @param mixed $arg,... Data values |
|
3167 | * @return float |
|
3168 | */ |
|
3169 | public static function STDEVP() |
|
3170 | { |
|
3171 | $aArgs = Functions::flattenArrayIndexed(func_get_args()); |
|
3172 | ||
3173 | $returnValue = null; |
|
3174 | ||
3175 | $aMean = self::AVERAGE($aArgs); |
|
3176 | if (!is_null($aMean)) { |
|
3177 | $aCount = 0; |
|
3178 | foreach ($aArgs as $k => $arg) { |
|
3179 | if ((is_bool($arg)) && |
|
3180 | ((!Functions::isCellValue($k)) || (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE))) { |
|
3181 | $arg = (integer) $arg; |
|
3182 | } |
|
3183 | // Is it a numeric value? |
|
3184 | if ((is_numeric($arg)) && (!is_string($arg))) { |
|
3185 | if (is_null($returnValue)) { |
|
3186 | $returnValue = pow(($arg - $aMean), 2); |
|
3187 | } else { |
|
3188 | $returnValue += pow(($arg - $aMean), 2); |
|
3189 | } |
|
3190 | ++$aCount; |
|
3191 | } |
|
3192 | } |
|
3193 | ||
3194 | if (($aCount > 0) && ($returnValue >= 0)) { |
|
3195 | return sqrt($returnValue / $aCount); |
|
3196 | } |
|
3197 | } |
|
3198 | return Functions::DIV0(); |
|
3199 | } |
|
3200 | ||
3201 | ||
3202 | /** |