diff --git a/Math/Functions/Beta.php b/Math/Functions/Beta.php index e101e1008..f40a72f31 100644 --- a/Math/Functions/Beta.php +++ b/Math/Functions/Beta.php @@ -99,8 +99,8 @@ final class Beta $pMinus = $p - 1.0; $h = 1.0 - $pqSum * $x / $pPlus; - if (\abs($h) < 2.23e-308) { - $h = 2.23e-308; + if (\abs($h) < 1.18e-37) { + $h = 1.18e-37; } $h = 1.0 / $h; @@ -112,33 +112,33 @@ final class Beta $m2 = 2 * $m; $d = $m * ($q - $m) * $x / (($pMinus + $m2) * ($p + $m2)); $h = 1.0 + $d * $h; - if (\abs($h) < 2.23e-308) { - $h = 2.23e-308; + if (\abs($h) < 1.18e-37) { + $h = 1.18e-37; } $h = 1.0 / $h; $c = 1.0 + $d / $c; - if (\abs($c) < 2.23e-308) { - $c = 2.23e-308; + if (\abs($c) < 1.18e-37) { + $c = 1.18e-37; } $frac *= $h * $c; $d = -($p + $m) * ($pqSum + $m) * $x / (($p + $m2) * ($pPlus + $m2)); $h = 1.0 + $d * $h; - if (\abs($h) < 2.23e-308) { - $h = 2.23e-308; + if (\abs($h) < 1.18e-37) { + $h = 1.18e-37; } $h = 1.0 / $h; $c = 1.0 + $d / $c; - if (\abs($c) < 2.23e-308) { - $c = 2.23e-308; + if (\abs($c) < 1.18e-37) { + $c = 1.18e-37; } $delta = $h * $c; $frac *= $delta; ++$m; - } while ($m < 1000000000 && \abs($delta - 1.0) > 8.88e-16); + } while ($m < 1000000 && \abs($delta - 1.0) > 8.88e-16); return $frac; } diff --git a/Math/Functions/Gamma.php b/Math/Functions/Gamma.php index f0a8e1381..ae6019707 100644 --- a/Math/Functions/Gamma.php +++ b/Math/Functions/Gamma.php @@ -275,7 +275,7 @@ final class Gamma private static function gammaFraction(float $a, float $x) : float { $b = $x + 1.0 - $a; - $c = 1.0 / 2.23e-308; + $c = 1.0 / 1.18e-37; $d = 1.0 / $b; $h = $d; $del = 0.0; @@ -286,12 +286,12 @@ final class Gamma $d = $an * $d + $b; $c = $b + $an / $c; - if (\abs($c) < 2.23e-308) { - $c = 2.23e-308; + if (\abs($c) < 1.18e-37) { + $c = 1.18e-37; } - if (\abs($d) < 2.23e-308) { - $d = 2.23e-308; + if (\abs($d) < 1.18e-37) { + $d = 1.18e-37; } $d = 1.0 / $d;