You are here

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

* Evaluates of continued fraction part of incomplete beta function. * Based on an idea from Numerical Recipes (W.H. Press et al, 1992). * @author Jaco van Kooten

1 call to PHPExcel_Calculation_Statistical::_betaFraction()
PHPExcel_Calculation_Statistical::_incompleteBeta in vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Statistical.php
* 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). *

File

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

Class

PHPExcel_Calculation_Statistical
PHPExcel_Calculation_Statistical

Code

private static function _betaFraction($x, $p, $q) {
  $c = 1.0;
  $sum_pq = $p + $q;
  $p_plus = $p + 1.0;
  $p_minus = $p - 1.0;
  $h = 1.0 - $sum_pq * $x / $p_plus;
  if (abs($h) < XMININ) {
    $h = XMININ;
  }
  $h = 1.0 / $h;
  $frac = $h;
  $m = 1;
  $delta = 0.0;
  while ($m <= MAX_ITERATIONS && abs($delta - 1.0) > PRECISION) {
    $m2 = 2 * $m;

    // even index for d
    $d = $m * ($q - $m) * $x / (($p_minus + $m2) * ($p + $m2));
    $h = 1.0 + $d * $h;
    if (abs($h) < XMININ) {
      $h = XMININ;
    }
    $h = 1.0 / $h;
    $c = 1.0 + $d / $c;
    if (abs($c) < XMININ) {
      $c = XMININ;
    }
    $frac *= $h * $c;

    // odd index for d
    $d = -($p + $m) * ($sum_pq + $m) * $x / (($p + $m2) * ($p_plus + $m2));
    $h = 1.0 + $d * $h;
    if (abs($h) < XMININ) {
      $h = XMININ;
    }
    $h = 1.0 / $h;
    $c = 1.0 + $d / $c;
    if (abs($c) < XMININ) {
      $c = XMININ;
    }
    $delta = $h * $c;
    $frac *= $delta;
    ++$m;
  }
  return $frac;
}