You are here

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

* VARFunc * * Estimates variance based on a sample. * * Excel Function: * VAR(value1[,value2[, ...]]) * * @access public * @category Statistical Functions *

Parameters

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

2 calls to PHPExcel_Calculation_Statistical::VARFunc()
PHPExcel_Calculation_Database::DVAR in vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Database.php
* DVAR * * Estimates the variance of a population based on a sample by using the numbers in a column * of a list or database that match conditions that you specify. * * Excel Function: * DVAR(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 3414

Class

PHPExcel_Calculation_Statistical
PHPExcel_Calculation_Statistical

Code

public static function VARFunc() {

  // 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 > 1) {
    $summerA *= $aCount;
    $summerB *= $summerB;
    $returnValue = ($summerA - $summerB) / ($aCount * ($aCount - 1));
  }
  return $returnValue;
}