| @@ 3037-3073 (lines=37) @@ | ||
| 3034 | * @param mixed $arg,... Data values |
|
| 3035 | * @return float |
|
| 3036 | */ |
|
| 3037 | public static function STDEVA() { |
|
| 3038 | $aArgs = PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args()); |
|
| 3039 | ||
| 3040 | // Return value |
|
| 3041 | $returnValue = null; |
|
| 3042 | ||
| 3043 | $aMean = self::AVERAGEA($aArgs); |
|
| 3044 | if (!is_null($aMean)) { |
|
| 3045 | $aCount = -1; |
|
| 3046 | foreach ($aArgs as $k => $arg) { |
|
| 3047 | if ((is_bool($arg)) && |
|
| 3048 | (!PHPExcel_Calculation_Functions::isMatrixValue($k))) { |
|
| 3049 | } else { |
|
| 3050 | // Is it a numeric value? |
|
| 3051 | if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) { |
|
| 3052 | if (is_bool($arg)) { |
|
| 3053 | $arg = (integer) $arg; |
|
| 3054 | } elseif (is_string($arg)) { |
|
| 3055 | $arg = 0; |
|
| 3056 | } |
|
| 3057 | if (is_null($returnValue)) { |
|
| 3058 | $returnValue = pow(($arg - $aMean),2); |
|
| 3059 | } else { |
|
| 3060 | $returnValue += pow(($arg - $aMean),2); |
|
| 3061 | } |
|
| 3062 | ++$aCount; |
|
| 3063 | } |
|
| 3064 | } |
|
| 3065 | } |
|
| 3066 | ||
| 3067 | // Return |
|
| 3068 | if (($aCount > 0) && ($returnValue >= 0)) { |
|
| 3069 | return sqrt($returnValue / $aCount); |
|
| 3070 | } |
|
| 3071 | } |
|
| 3072 | return PHPExcel_Calculation_Functions::DIV0(); |
|
| 3073 | } // function STDEVA() |
|
| 3074 | ||
| 3075 | ||
| 3076 | /** |
|
| @@ 3136-3172 (lines=37) @@ | ||
| 3133 | * @param mixed $arg,... Data values |
|
| 3134 | * @return float |
|
| 3135 | */ |
|
| 3136 | public static function STDEVPA() { |
|
| 3137 | $aArgs = PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args()); |
|
| 3138 | ||
| 3139 | // Return value |
|
| 3140 | $returnValue = null; |
|
| 3141 | ||
| 3142 | $aMean = self::AVERAGEA($aArgs); |
|
| 3143 | if (!is_null($aMean)) { |
|
| 3144 | $aCount = 0; |
|
| 3145 | foreach ($aArgs as $k => $arg) { |
|
| 3146 | if ((is_bool($arg)) && |
|
| 3147 | (!PHPExcel_Calculation_Functions::isMatrixValue($k))) { |
|
| 3148 | } else { |
|
| 3149 | // Is it a numeric value? |
|
| 3150 | if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) { |
|
| 3151 | if (is_bool($arg)) { |
|
| 3152 | $arg = (integer) $arg; |
|
| 3153 | } elseif (is_string($arg)) { |
|
| 3154 | $arg = 0; |
|
| 3155 | } |
|
| 3156 | if (is_null($returnValue)) { |
|
| 3157 | $returnValue = pow(($arg - $aMean),2); |
|
| 3158 | } else { |
|
| 3159 | $returnValue += pow(($arg - $aMean),2); |
|
| 3160 | } |
|
| 3161 | ++$aCount; |
|
| 3162 | } |
|
| 3163 | } |
|
| 3164 | } |
|
| 3165 | ||
| 3166 | // Return |
|
| 3167 | if (($aCount > 0) && ($returnValue >= 0)) { |
|
| 3168 | return sqrt($returnValue / $aCount); |
|
| 3169 | } |
|
| 3170 | } |
|
| 3171 | return PHPExcel_Calculation_Functions::DIV0(); |
|
| 3172 | } // function STDEVPA() |
|
| 3173 | ||
| 3174 | ||
| 3175 | /** |
|