本文整理汇总了PHP中Statistics::lanczos方法的典型用法代码示例。如果您正苦于以下问题:PHP Statistics::lanczos方法的具体用法?PHP Statistics::lanczos怎么用?PHP Statistics::lanczos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Statistics
的用法示例。
在下文中一共展示了Statistics::lanczos方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: logGamma
/**
* Returns the value of log gamma(x) for x > 0.
*/
public static function logGamma($x)
{
$ret;
$half_log_2_pi = 0.5 * log(2.0 * M_PI);
$lanczos_g = 607.0 / 128.0;
if (is_nan($x) || $x <= 0.0) {
$ret = NAN;
} else {
if ($x < 0.5) {
return Statistics::logGamma1p($x) - log($x);
} else {
if ($x <= 2.5) {
return Statistics::logGamma1p($x - 0.5 - 0.5);
} else {
if ($x <= 8.0) {
$n = intval(floor($x - 1.5));
$prod = 1.0;
for ($i = 1; $i <= $n; $i++) {
$prod = $prod * (x - $i);
}
return Statistics::logGamma1p($x - ($n + 1)) + log($prod);
} else {
$sum = Statistics::lanczos($x);
$tmp = $x + $lanczos_g + 0.5;
$ret = ($x + 0.5) * log($tmp) - $tmp + $half_log_2_pi + log($sum / $x);
}
}
}
}
return $ret;
}
示例2: notify
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));
printf("riskIters: [%s]\n", implode(', ', $rtgm->riskIters));
} catch (Exception $e) {
print $e->getMessage() . "\n";
}
exit($exit_code);