You are here

public static function PHPExcel_Calculation_Statistical::VARPA 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::VARPA()

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

Parameters

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

File

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

Class

PHPExcel_Calculation_Statistical
PHPExcel_Calculation_Statistical

Code

public static function VARPA() {

  // Return value
  $returnValue = PHPExcel_Calculation_Functions::DIV0();
  $summerA = $summerB = 0;

  // Loop through arguments
  $aArgs = PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args());
  $aCount = 0;
  foreach ($aArgs as $k => $arg) {
    if (is_string($arg) && PHPExcel_Calculation_Functions::isValue($k)) {
      return PHPExcel_Calculation_Functions::VALUE();
    }
    elseif (is_string($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;
        }
        $summerA += $arg * $arg;
        $summerB += $arg;
        ++$aCount;
      }
    }
  }

  // Return
  if ($aCount > 0) {
    $summerA *= $aCount;
    $summerB *= $summerB;
    $returnValue = ($summerA - $summerB) / ($aCount * $aCount);
  }
  return $returnValue;
}