You are here

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

* VARA * * Estimates variance based on a sample, including numbers, text, and logical values * * Excel Function: * VARA(value1[,value2[, ...]]) * * @access public * @category Statistical Functions *

Parameters

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

File

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

Class

PHPExcel_Calculation_Statistical
PHPExcel_Calculation_Statistical

Code

public static function VARA() {

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