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