You are here

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

* GAMMADIST * * Returns the gamma distribution. * *

Parameters

float $value Value at which you want to evaluate the distribution: * @param float $a Parameter to the distribution * @param float $b Parameter to the distribution * @param boolean $cumulative * @return float *

1 call to PHPExcel_Calculation_Statistical::GAMMADIST()
PHPExcel_Calculation_Statistical::GAMMAINV in vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Statistical.php
* GAMMAINV * * Returns the inverse of the beta distribution. * *

File

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

Class

PHPExcel_Calculation_Statistical
PHPExcel_Calculation_Statistical

Code

public static function GAMMADIST($value, $a, $b, $cumulative) {
  $value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
  $a = PHPExcel_Calculation_Functions::flattenSingleValue($a);
  $b = PHPExcel_Calculation_Functions::flattenSingleValue($b);
  if (is_numeric($value) && is_numeric($a) && is_numeric($b)) {
    if ($value < 0 || $a <= 0 || $b <= 0) {
      return PHPExcel_Calculation_Functions::NaN();
    }
    if (is_numeric($cumulative) || is_bool($cumulative)) {
      if ($cumulative) {
        return self::_incompleteGamma($a, $value / $b) / self::_gamma($a);
      }
      else {
        return 1 / (pow($b, $a) * self::_gamma($a)) * pow($value, $a - 1) * exp(0 - $value / $b);
      }
    }
  }
  return PHPExcel_Calculation_Functions::VALUE();
}