Skip to content

Commit

Permalink
Works! (#161)
Browse files Browse the repository at this point in the history
* use log1p when appropriate
* Fix left bitshift
  • Loading branch information
Beakerboy committed Oct 11, 2021
1 parent 8d35062 commit 8e653ba
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Probability/Distribution/Continuous/StudentT.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function pdf(float $t): float
$l_x2n = log(1 + $x2n) / 2;
$u = $ν * $l_x2n;
} else {
$l_x2n = log($x2n + 1) / 2;
$l_x2n = log1p($x2n) / 2;
$u = -1* self::bd0($ν / 2, ($ν + $t**2) / 2) + $t**2 / 2;
}

Expand Down Expand Up @@ -237,7 +237,7 @@ static function bd0(float $x, float $np)
for ($j = 1; $j < 1000; $j++) {
$ej *= $v;
$stemp = $s;
$s += $ej / (($j *= 2) + 1); // Does $j get doubled here?
$s += $ej / (($j * 2) + 1);
if ($s == $stemp) {
return $s;
}
Expand Down Expand Up @@ -271,7 +271,7 @@ static function stirlerr (float $n)
0.03316287351993628748511048, /* 2.5 */
0.02767792568499833914878929, /* 3.0 */
0.02374616365629749597132920, /* 3.5 */
0.02079067210376509311152277, /* 4.0 */
0.02079067210376509311152277, /* 4.0 */
0.01848845053267318523077934, /* 4.5 */
0.01664469118982119216319487, /* 5.0 */
0.01513497322191737887351255, /* 5.5 */
Expand Down

0 comments on commit 8e653ba

Please sign in to comment.