コード例 #1
0
ファイル: Functions.php プロジェクト: hostellerie/nexpro
 /**
  * STDEVPA
  *
  * Calculates standard deviation based on the entire population, including numbers, text, and logical values
  *
  * @param	array of mixed		Data Series
  * @return  float
  */
 public static function STDEVPA()
 {
     // Return value
     $returnValue = null;
     $aMean = PHPExcel_Calculation_Functions::AVERAGEA(func_get_args());
     if (!is_null($aMean)) {
         $aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
         $aCount = 0;
         foreach ($aArgs as $arg) {
             // Is it a numeric value?
             if (is_numeric($arg) || is_bool($arg) || is_string($arg) & $arg != '') {
                 if (is_bool($arg)) {
                     $arg = (int) $arg;
                 } elseif (is_string($arg)) {
                     $arg = 0;
                 }
                 if (is_null($returnValue)) {
                     $returnValue = pow($arg - $aMean, 2);
                 } else {
                     $returnValue += pow($arg - $aMean, 2);
                 }
                 ++$aCount;
             }
         }
         // Return
         if ($aCount > 0 && $returnValue > 0) {
             return sqrt($returnValue / $aCount);
         }
     }
     return self::$_errorCodes['divisionbyzero'];
 }