/** * Returns the value of log gamma(1 + x) for -0.5 <= x <= 1.5. */ public static function logGamma1p($x) { if ($x < -0.5) { throw new Exception($x . " is smaller then the minimum -0.5"); } if ($x > 1.5) { throw new Exception($x . " is larger then the maximum 1.5"); } return -1.0 * log1p(Statistics::invGamma1pm1($x)); }
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) { notify('InvGamma1pm1 too small', $ex1, $ex1); } try { Statistics::invGamma1pm1(2.5); notify('InvGamma1pm1 too large', "Exception thrown", "Ok"); } catch (Exception $ex1) { notify('InvGamma1pm1 too large', $ex1, $ex1); } notify('Lanczos', 19.194552097849, Statistics::lanczos(0.5)); notify('LogGamma', 0.5723649429247, Statistics::logGamma(0.5)); notify('RegularizedGammaP', 0.77932863808015, Statistics::regularizedGammaP(0.5, 0.75, 1.0E-15, 10000)); notify('RegularizedGammaQ', 0.061368829139402, Statistics::regularizedGammaQ(0.5, 1.75, 1.0E-15, 10000)); // Global test $rtgm->calculate(); notify('Get risk coefficient', $riskCoeff, $rtgm->riskCoeff); notify('Get rtgm iter', $rtgmIters, $rtgm->rtgmIters); notify('Get risk iter', $riskIters, $rtgm->riskIters); printf("\nriskCoeff: %s\n", $rtgm->riskCoeff); printf("rtgmIters: [%s]\n", implode(', ', $rtgm->rtgmIters));