You are here

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

* HYPGEOMDIST * * Returns the hypergeometric distribution. HYPGEOMDIST returns the probability of a given number of * sample successes, given the sample size, population successes, and population size. * *

Parameters

float $sampleSuccesses Number of successes in the sample: * @param float $sampleNumber Size of the sample * @param float $populationSuccesses Number of successes in the population * @param float $populationNumber Population size * @return float *

File

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

Class

PHPExcel_Calculation_Statistical
PHPExcel_Calculation_Statistical

Code

public static function HYPGEOMDIST($sampleSuccesses, $sampleNumber, $populationSuccesses, $populationNumber) {
  $sampleSuccesses = floor(PHPExcel_Calculation_Functions::flattenSingleValue($sampleSuccesses));
  $sampleNumber = floor(PHPExcel_Calculation_Functions::flattenSingleValue($sampleNumber));
  $populationSuccesses = floor(PHPExcel_Calculation_Functions::flattenSingleValue($populationSuccesses));
  $populationNumber = floor(PHPExcel_Calculation_Functions::flattenSingleValue($populationNumber));
  if (is_numeric($sampleSuccesses) && is_numeric($sampleNumber) && is_numeric($populationSuccesses) && is_numeric($populationNumber)) {
    if ($sampleSuccesses < 0 || $sampleSuccesses > $sampleNumber || $sampleSuccesses > $populationSuccesses) {
      return PHPExcel_Calculation_Functions::NaN();
    }
    if ($sampleNumber <= 0 || $sampleNumber > $populationNumber) {
      return PHPExcel_Calculation_Functions::NaN();
    }
    if ($populationSuccesses <= 0 || $populationSuccesses > $populationNumber) {
      return PHPExcel_Calculation_Functions::NaN();
    }
    return PHPExcel_Calculation_MathTrig::COMBIN($populationSuccesses, $sampleSuccesses) * PHPExcel_Calculation_MathTrig::COMBIN($populationNumber - $populationSuccesses, $sampleNumber - $sampleSuccesses) / PHPExcel_Calculation_MathTrig::COMBIN($populationNumber, $sampleNumber);
  }
  return PHPExcel_Calculation_Functions::VALUE();
}