You are here

public static function PHPExcel_Calculation_Statistical::VARP in Loft Data Grids 6.2

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

* VARP * * Calculates variance based on the entire population * * Excel Function: * VARP(value1[,value2[, ...]]) * * @access public * @category Statistical Functions *

Parameters

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

2 calls to PHPExcel_Calculation_Statistical::VARP()
PHPExcel_Calculation_Database::DVARP in vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Database.php
* DVARP * * Calculates the variance of a population based on the entire population by using the numbers * in a column of a list or database that match conditions that you specify. * * Excel Function: * DVARP(database,field,criteria) * …
PHPExcel_Calculation_MathTrig::SUBTOTAL in vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/MathTrig.php
* SUBTOTAL * * Returns a subtotal in a list or database. * *

File

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

Class

PHPExcel_Calculation_Statistical
PHPExcel_Calculation_Statistical

Code

public static function VARP() {

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

  // Loop through arguments
  $aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
  $aCount = 0;
  foreach ($aArgs as $arg) {
    if (is_bool($arg)) {
      $arg = (int) $arg;
    }

    // Is it a numeric value?
    if (is_numeric($arg) && !is_string($arg)) {
      $summerA += $arg * $arg;
      $summerB += $arg;
      ++$aCount;
    }
  }

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