コード例 #1
0
ファイル: Statistical.php プロジェクト: sysraj86/carnivalcrm
 /**
  *	STDEVP
  *
  *	Calculates standard deviation based on the entire population
  *
  *	Excel Function:
  *		STDEVP(value1[,value2[, ...]])
  *
  *	@access	public
  *	@category Statistical Functions
  *	@param	mixed		$arg,...		Data values
  *	@return	float
  */
 public static function STDEVP()
 {
     $aArgs = PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args());
     // Return value
     $returnValue = null;
     $aMean = self::AVERAGE($aArgs);
     if (!is_null($aMean)) {
         $aCount = 0;
         foreach ($aArgs as $k => $arg) {
             if (is_bool($arg) && (!PHPExcel_Calculation_Functions::isCellValue($k) || PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE)) {
                 $arg = (int) $arg;
             }
             // Is it a numeric value?
             if (is_numeric($arg) && !is_string($arg)) {
                 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 PHPExcel_Calculation_Functions::DIV0();
 }