Skip to content

Commit

Permalink
phpcs
Browse files Browse the repository at this point in the history
  • Loading branch information
Beakerboy committed Oct 11, 2021
1 parent 8e653ba commit d8f8def
Showing 1 changed file with 44 additions and 44 deletions.
88 changes: 44 additions & 44 deletions src/Probability/Distribution/Continuous/StudentT.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,26 +223,26 @@ public function variance(): float
* evaluation fails, and evaluation is based on the Taylor series
* of log((1+v)/(1-v)) with v = (x-M)/(x+M) = (x-np)/(x+np).
*/
static function bd0(float $x, float $np)
private static function bd0(float $x, float $np)
{
$DBL_MIN = 2.23e-308; // Check This
if (abs($x - $np) < 0.1 * ($x + $np)) {
$v = ($x - $np) / ($x + $np);
$s = ($x - $np) * $v;
if(abs($s) < $DBL_MIN) {
$v = ($x - $np) / ($x + $np);
$s = ($x - $np) * $v;
if(abs($s) < $DBL_MIN) {
return $s;
}
$ej = 2 * $x * $v;
$v *= $v;
for ($j = 1; $j < 1000; $j++) {
$ej *= $v;
$stemp = $s;
$s += $ej / (($j * 2) + 1);
if ($s == $stemp) {
$ej = 2 * $x * $v;
$v *= $v;
for ($j = 1; $j < 1000; $j++) {
$ej *= $v;
$stemp = $s;
$s += $ej / (($j * 2) + 1);
if ($s == $stemp) {
return $s;
}
}
//MATHLIB_WARNING4("bd0(%g, %g): T.series failed to converge in 1000 it.; s=%g, ej/(2j+1)=%g\n", x, np, s, ej/((1000<<1)+1));
}
}
//MATHLIB_WARNING4("bd0(%g, %g): T.series failed to converge in 1000 it.; s=%g, ej/(2j+1)=%g\n", x, np, s, ej/((1000<<1)+1));
}
return ($x * log($x / $np) + $np - $x);
}
Expand All @@ -254,7 +254,7 @@ static function bd0(float $x, float $np)
* For other n < 15, uses lgamma directly (don't use this to
* write lgamma!)
*/
static function stirlerr (float $n)
private static function stirlerr (float $n)
{
$S0 = 0.083333333333333333333; // 1/12
$S1 = 0.00277777777777777777778; // 1/360
Expand All @@ -265,44 +265,44 @@ static function stirlerr (float $n)
$sferr_halves = [
0.0, /* n=0 - wrong, place holder only */
0.1534264097200273452913848, /* 0.5 */
0.0810614667953272582196702, /* 1.0 */
0.0548141210519176538961390, /* 1.5 */
0.0413406959554092940938221, /* 2.0 */
0.03316287351993628748511048, /* 2.5 */
0.02767792568499833914878929, /* 3.0 */
0.02374616365629749597132920, /* 3.5 */
0.0810614667953272582196702, /* 1.0 */
0.0548141210519176538961390, /* 1.5 */
0.0413406959554092940938221, /* 2.0 */
0.03316287351993628748511048, /* 2.5 */
0.02767792568499833914878929, /* 3.0 */
0.02374616365629749597132920, /* 3.5 */
0.02079067210376509311152277, /* 4.0 */
0.01848845053267318523077934, /* 4.5 */
0.01664469118982119216319487, /* 5.0 */
0.01513497322191737887351255, /* 5.5 */
0.01387612882307074799874573, /* 6.0 */
0.01281046524292022692424986, /* 6.5 */
0.01189670994589177009505572, /* 7.0 */
0.01110455975820691732662991, /* 7.5 */
0.010411265261972096497478567, /* 8.0 */
0.009799416126158803298389475, /* 8.5 */
0.009255462182712732917728637, /* 9.0 */
0.008768700134139385462952823, /* 9.5 */
0.008330563433362871256469318, /* 10.0 */
0.007934114564314020547248100, /* 10.5 */
0.007573675487951840794972024, /* 11.0 */
0.007244554301320383179543912, /* 11.5 */
0.006942840107209529865664152, /* 12.0 */
0.006665247032707682442354394, /* 12.5 */
0.006408994188004207068439631, /* 13.0 */
0.006171712263039457647532867, /* 13.5 */
0.005951370112758847735624416, /* 14.0 */
0.005746216513010115682023589, /* 14.5 */
0.005554733551962801371038690, /* 15.0 */
0.01513497322191737887351255, /* 5.5 */
0.01387612882307074799874573, /* 6.0 */
0.01281046524292022692424986, /* 6.5 */
0.01189670994589177009505572, /* 7.0 */
0.01110455975820691732662991, /* 7.5 */
0.010411265261972096497478567, /* 8.0 */
0.009799416126158803298389475, /* 8.5 */
0.009255462182712732917728637, /* 9.0 */
0.008768700134139385462952823, /* 9.5 */
0.008330563433362871256469318, /* 10.0 */
0.007934114564314020547248100, /* 10.5 */
0.007573675487951840794972024, /* 11.0 */
0.007244554301320383179543912, /* 11.5 */
0.006942840107209529865664152, /* 12.0 */
0.006665247032707682442354394, /* 12.5 */
0.006408994188004207068439631, /* 13.0 */
0.006171712263039457647532867, /* 13.5 */
0.005951370112758847735624416, /* 14.0 */
0.005746216513010115682023589, /* 14.5 */
0.005554733551962801371038690, /* 15.0 */
];

if ($n <= 15.0) {
$nn = $n + $n;
if ($nn == (int)$nn) {
$nn = $n + $n;
if ($nn == (int)$nn) {
return $sferr_halves[$nn];
}
$M_LN_SQRT_2PI = log(sqrt(2 * \pi()));
return self::lgammafn($n + 1) - ($n + 0.5) * log($n) + $n - $M_LN_SQRT_2PI;
return self::lgammafn($n + 1) - ($n + 0.5) * log($n) + $n - $M_LN_SQRT_2PI;
}

$nn = $n * $n;
Expand Down

0 comments on commit d8f8def

Please sign in to comment.