@@ -977,25 +977,31 @@ function _gamma_inc_inv(a::Float64, p::Float64, q::Float64)
977
977
end
978
978
979
979
px, qx = gamma_inc (a, x, 0 )
980
- ck1 = pcase ? - r* (px - p) : r* (qx - q)
981
- ck2 = (x - a + 1.0 )/ (2.0 * x)
982
- ck3 = (@horner (x, @horner (a, 1 , - 3 , 2 ), @horner (a, 4 , - 4 ), 2 ))/ (6 * x²)
983
- r = ck1
984
-
985
- # This check is not in the invincgam subroutine from IncgamFI but it probably
986
- # should be since the routine fails to compute a finite value for very small p
987
- if ! isfinite (ck3)
988
- break
989
- end
990
980
991
- if a > 0.1
992
- x0 = @horner (r, x, 1.0 , ck2, ck3)
993
- else
994
- if a > 0.05
995
- x0 = @horner (r, x, 1.0 , ck2)
981
+ ck1 = pcase ? - r* (px - p) : r* (qx - q)
982
+ if a > 0.05
983
+ ck2 = (x - a + 1.0 )/ (2.0 * x)
984
+
985
+ # This check is not in the invincgam subroutine from IncgamFI but it probably
986
+ # should be since the routine fails to compute a finite value for very small p
987
+ if ! isfinite (ck2)
988
+ break
989
+ end
990
+
991
+ if a > 0.1
992
+ ck3 = (@horner (x, @horner (a, 1 , - 3 , 2 ), @horner (a, 4 , - 4 ), 2 ))/ (6 * x²)
993
+
994
+ # This check is not in the invincgam subroutine from IncgamFI but it probably
995
+ # should be since the routine fails to compute a finite value for very small p
996
+ if ! isfinite (ck3)
997
+ break
998
+ end
999
+ x0 = @horner (ck1, x, 1.0 , ck2, ck3)
996
1000
else
997
- x0 = x + r
1001
+ x0 = @horner (ck1, x, 1.0 , ck2)
998
1002
end
1003
+ else
1004
+ x0 = x + ck1
999
1005
end
1000
1006
1001
1007
t = abs (x/ x0 - 1.0 )
0 commit comments