public function getCdf()
 {
     if ($this->cdf == null) {
         $size = count($this->model->xs);
         $this->cdf = new XY_Series($size);
         for ($i = 0; $i < $size; $i++) {
             $this->cdf->xs[$i] = $this->model->xs[$i];
             $this->cdf->ys[$i] = RTGM_Util::logNormalCumProb($this->model->xs[$i], log($this->median), $this->beta);
         }
     }
     return $this->cdf;
 }
 private function riskIntegral($fragPDF, $hazCurve)
 {
     // multiply fragPDF in place
     $fragPDF->ys = RTGM_Util::multiply($fragPDF->ys, $hazCurve->ys);
     $this->_pushJsonIteration('integrand', $fragPDF->ys);
     $xs = array();
     $ys = array();
     for ($i = 0; $i < count($fragPDF->ys); $i++) {
         $xs[] = $fragPDF->xs[$i];
         $ys[] = $fragPDF->ys[$i];
         $r[] = RTGM_Util::trapz($xs, $ys);
     }
     $this->_pushJsonIteration('integral', $r);
     return RTGM_Util::trapz($fragPDF->xs, $fragPDF->ys);
 }
 private static function dataIndex($data, $value)
 {
     $i = RTGM_Util::binary_search($data, $value);
     // adjust index for low value (-1) and in-sequence insertion pt
     // Note: below works in java as expected but not in PHP
     //		$i = ($i == -1) ? 0 : ($i < 0) ? -$i - 2 : $i;
     $i = $i == -1 ? 0 : ($i < 0 ? -$i - 2 : $i);
     // adjust hi index to next to last index
     return $i >= count($data) - 1 ? --$i : $i;
 }
 notify('Binary search not found', -4, RTGM_Util::binary_search($a, 6.0));
 notify('Build Sequence', 178, count(RTGM_Util::buildSequence(log($min_sa), log($xs[count($xs) - 1]), log($usampling_factor), true)));
 notify('Build Sequence Inf/NaN', 0, count(RTGM_Util::buildSequence(INF, NAN, 1, true)));
 $a2 = array(1, 2, 3);
 notify('Exp', array(2.718281828459, 7.3890560989307, 20.085536923188), RTGM_Util::exp($a2));
 notify('Find Log Log X', $uhgm, RTGM_Util::findLogLogX($xs, $ys, $afe4uhgm));
 notify('Find Log Log Y', $afe4uhgm, RTGM_Util::findLogLogY($xs, $ys, $uhgm));
 notify('Log Normal Cumulative Prob', 0.012893887361471, RTGM_Util::logNormalCumProb(1.3, 1.6, 0.6));
 notify('Log Normal Cumulative Prob (0)', 0.0, RTGM_Util::logNormalCumProb(0.0, 1.6, 0.6));
 notify('Log Normal Density', 0.042613954514149, RTGM_Util::logNormalDensity(1.3, 1.6, 0.6));
 notify('Log Normal Density (0)', 0.0, RTGM_Util::logNormalDensity(0.0, 1.6, 0.6));
 $a3 = array(1, 2, 3);
 notify('Multiply', array(3, 8, 15), RTGM_Util::multiply($a3, array(3, 4, 5)));
 $a4 = array(10, 20, 30);
 notify('Scale', array(1, 2, 3), RTGM_Util::scale($a4, 0.1));
 notify('Trapz', $riskTmp, RTGM_Util::trapz($xs, $ys));
 // Statistics method tests
 notify('ErfInv', 0.47693627620447, Statistics::erfInv(0.5));
 notify('InverseCumulativeProbabilty', 0.67448975019608, Statistics::inverseCumulativeProbability(0.75));
 notify('InverseCumulativeProbabilty (3 args)', 2.0046938501176, Statistics::inverseCumulativeProbability(0.75, 1.6, 0.6));
 try {
     Statistics::inverseCumulativeProbability(2.5);
     notify('InverseCumulativeProbabilty out of range', "Exception thrown", "Ok");
 } catch (Exception $ex1) {
     notify('InverseCumulativeProbabilty out of range', $ex1, $ex1);
 }
 notify('InvGamma1pm1', 0.12837916709551, Statistics::invGamma1pm1(0.5));
 try {
     Statistics::invGamma1pm1(-2.5);
     notify('InvGamma1pm1 too small', "Exception thrown", "Ok");
 } catch (Exception $ex1) {