@@ 3035-3067 (lines=33) @@ | ||
3032 | * @param mixed $arg,... Data values |
|
3033 | * @return float |
|
3034 | */ |
|
3035 | public static function STDEV() |
|
3036 | { |
|
3037 | $aArgs = Functions::flattenArrayIndexed(func_get_args()); |
|
3038 | ||
3039 | // Return value |
|
3040 | $returnValue = null; |
|
3041 | ||
3042 | $aMean = self::AVERAGE($aArgs); |
|
3043 | if (!is_null($aMean)) { |
|
3044 | $aCount = -1; |
|
3045 | foreach ($aArgs as $k => $arg) { |
|
3046 | if ((is_bool($arg)) && |
|
3047 | ((!Functions::isCellValue($k)) || (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE))) { |
|
3048 | $arg = (integer) $arg; |
|
3049 | } |
|
3050 | // Is it a numeric value? |
|
3051 | if ((is_numeric($arg)) && (!is_string($arg))) { |
|
3052 | if (is_null($returnValue)) { |
|
3053 | $returnValue = pow(($arg - $aMean), 2); |
|
3054 | } else { |
|
3055 | $returnValue += pow(($arg - $aMean), 2); |
|
3056 | } |
|
3057 | ++$aCount; |
|
3058 | } |
|
3059 | } |
|
3060 | ||
3061 | // Return |
|
3062 | if (($aCount > 0) && ($returnValue >= 0)) { |
|
3063 | return sqrt($returnValue / $aCount); |
|
3064 | } |
|
3065 | } |
|
3066 | ||
3067 | return Functions::DIV0(); |
|
3068 | } |
|
3069 | ||
3070 | /** |
|
@@ 3132-3162 (lines=31) @@ | ||
3129 | * @param mixed $arg,... Data values |
|
3130 | * @return float |
|
3131 | */ |
|
3132 | public static function STDEVP() |
|
3133 | { |
|
3134 | $aArgs = Functions::flattenArrayIndexed(func_get_args()); |
|
3135 | ||
3136 | $returnValue = null; |
|
3137 | ||
3138 | $aMean = self::AVERAGE($aArgs); |
|
3139 | if (!is_null($aMean)) { |
|
3140 | $aCount = 0; |
|
3141 | foreach ($aArgs as $k => $arg) { |
|
3142 | if ((is_bool($arg)) && |
|
3143 | ((!Functions::isCellValue($k)) || (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE))) { |
|
3144 | $arg = (integer) $arg; |
|
3145 | } |
|
3146 | // Is it a numeric value? |
|
3147 | if ((is_numeric($arg)) && (!is_string($arg))) { |
|
3148 | if (is_null($returnValue)) { |
|
3149 | $returnValue = pow(($arg - $aMean), 2); |
|
3150 | } else { |
|
3151 | $returnValue += pow(($arg - $aMean), 2); |
|
3152 | } |
|
3153 | ++$aCount; |
|
3154 | } |
|
3155 | } |
|
3156 | ||
3157 | if (($aCount > 0) && ($returnValue >= 0)) { |
|
3158 | return sqrt($returnValue / $aCount); |
|
3159 | } |
|
3160 | } |
|
3161 | ||
3162 | return Functions::DIV0(); |
|
3163 | } |
|
3164 | ||
3165 | /** |