You are here

public static function PHPExcel_Calculation_Statistical::STDEVPA in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Statistical.php \PHPExcel_Calculation_Statistical::STDEVPA()

* STDEVPA * * Calculates standard deviation based on the entire population, including numbers, text, and logical values * * Excel Function: * STDEVPA(value1[,value2[, ...]]) * * @access public * @category Statistical Functions *

Parameters

mixed $arg,... Data values: * @return float

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Statistical.php, line 3143

Class

PHPExcel_Calculation_Statistical
PHPExcel_Calculation_Statistical

Code

public static function STDEVPA() {
  $aArgs = PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args());

  // Return value
  $returnValue = null;
  $aMean = self::AVERAGEA($aArgs);
  if (!is_null($aMean)) {
    $aCount = 0;
    foreach ($aArgs as $k => $arg) {
      if (is_bool($arg) && !PHPExcel_Calculation_Functions::isMatrixValue($k)) {
      }
      else {

        // 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 PHPExcel_Calculation_Functions::DIV0();
}