You are here

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

File

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

Class

PHPExcel_Calculation_Statistical
PHPExcel_Calculation_Statistical

Code

private static function _inverse_ncdf2($prob) {

  //	Approximation of inverse standard normal CDF developed by
  //	B. Moro, "The Full Monte," Risk 8(2), Feb 1995, 57-58.
  $a1 = 2.50662823884;
  $a2 = -18.61500062529;
  $a3 = 41.39119773534;
  $a4 = -25.44106049637;
  $b1 = -8.4735109309;
  $b2 = 23.08336743743;
  $b3 = -21.06224101826;
  $b4 = 3.13082909833;
  $c1 = 0.337475482272615;
  $c2 = 0.976169019091719;
  $c3 = 0.160797971491821;
  $c4 = 0.0276438810333863;
  $c5 = 0.0038405729373609;
  $c6 = 0.0003951896511919;
  $c7 = 3.21767881768E-5;
  $c8 = 2.888167364E-7;
  $c9 = 3.960315187E-7;
  $y = $prob - 0.5;
  if (abs($y) < 0.42) {
    $z = $y * $y;
    $z = $y * ((($a4 * $z + $a3) * $z + $a2) * $z + $a1) / (((($b4 * $z + $b3) * $z + $b2) * $z + $b1) * $z + 1);
  }
  else {
    if ($y > 0) {
      $z = log(-log(1 - $prob));
    }
    else {
      $z = log(-log($prob));
    }
    $z = $c1 + $z * ($c2 + $z * ($c3 + $z * ($c4 + $z * ($c5 + $z * ($c6 + $z * ($c7 + $z * ($c8 + $z * $c9)))))));
    if ($y < 0) {
      $z = -$z;
    }
  }
  return $z;
}