You are here

private static function PHPExcel_Calculation_Statistical::_incompleteBeta 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::_incompleteBeta()

* Incomplete beta function * * @author Jaco van Kooten * @author Paul Meagher * * The computation is based on formulas from Numerical Recipes, Chapter 6.4 (W.H. Press et al, 1992). *

Parameters

x require 0<=x<=1: * @param p require p>0 * @param q require q>0 * @return 0 if x<0, p<=0, q<=0 or p+q>2.55E305 and 1 if x>1 to avoid errors and over/underflow

1 call to PHPExcel_Calculation_Statistical::_incompleteBeta()
PHPExcel_Calculation_Statistical::BETADIST in vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Statistical.php
* BETADIST * * Returns the beta distribution. * *

File

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

Class

PHPExcel_Calculation_Statistical
PHPExcel_Calculation_Statistical

Code

private static function _incompleteBeta($x, $p, $q) {
  if ($x <= 0.0) {
    return 0.0;
  }
  elseif ($x >= 1.0) {
    return 1.0;
  }
  elseif ($p <= 0.0 || $q <= 0.0 || $p + $q > LOG_GAMMA_X_MAX_VALUE) {
    return 0.0;
  }
  $beta_gam = exp(0 - self::_logBeta($p, $q) + $p * log($x) + $q * log(1.0 - $x));
  if ($x < ($p + 1.0) / ($p + $q + 2.0)) {
    return $beta_gam * self::_betaFraction($x, $p, $q) / $p;
  }
  else {
    return 1.0 - $beta_gam * self::_betaFraction(1 - $x, $q, $p) / $q;
  }
}