当前位置: 首页>>代码示例>>PHP>>正文


PHP Statistics::regularizedGammaQ方法代码示例

本文整理汇总了PHP中Statistics::regularizedGammaQ方法的典型用法代码示例。如果您正苦于以下问题:PHP Statistics::regularizedGammaQ方法的具体用法?PHP Statistics::regularizedGammaQ怎么用?PHP Statistics::regularizedGammaQ使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Statistics的用法示例。


在下文中一共展示了Statistics::regularizedGammaQ方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: regularizedGammaP

 /**
  * Returns the regularized gamma function P(a, x).
  */
 public static function regularizedGammaP($a, $x, $epsilon, $maxIterations)
 {
     $ret;
     if (is_nan($a) || is_nan($x) || $a <= 0.0 || $x < 0.0) {
         $ret = NAN;
     } else {
         if ($x == 0.0) {
             $ret = 0.0;
         } else {
             if ($x >= $a + 1) {
                 // use regularizedGammaQ because it should converge faster in this
                 // case.
                 $ret = 1.0 - Statistics::regularizedGammaQ($a, $x, $epsilon, $maxIterations);
             } else {
                 // calculate series
                 $n = 0.0;
                 // current element index
                 $an = 1.0 / $a;
                 // n-th element in the series
                 $sum = $an;
                 // partial sum
                 while (abs($an / $sum) > $epsilon && $n < $maxIterations && $sum < INF) {
                     // compute next element in the series
                     $n = $n + 1.0;
                     $an = $an * ($x / ($a + $n));
                     // update partial sum
                     $sum = $sum + $an;
                 }
                 if ($n >= $maxIterations) {
                     throw new Exception("Statistics::reqularizedGammaP: " . "max # iterations reached: " . $maxIterations);
                 } else {
                     if (is_infinite($sum)) {
                         $ret = 1.0;
                     } else {
                         $ret = exp(-$x + $a * log($x) - Statistics::logGamma($a)) * $sum;
                     }
                 }
             }
         }
     }
     return $ret;
 }
开发者ID:ehunter-usgs,项目名称:earthquake-rtgm-calculator,代码行数:45,代码来源:Statistics.class.php

示例2: notify

    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);
?>

开发者ID:hasimpson-usgs,项目名称:earthquake-rtgm-calculator,代码行数:29,代码来源:RTGM.test.php


注:本文中的Statistics::regularizedGammaQ方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。