Removing underflow panic from cephes.IgamI
MODIFY
gamma_inc.go
gamma_inc.go
@@ -31,7 +31,8 @@ func GammaIncComp(a, x float64) float64 {
// is, it returns the x such that:
// GammaIncComp(a, x) = y
// The input argument a must be positive and y must be between 0 and 1
-// inclusive or GammaIncCompInv will panic.
+// inclusive or GammaIncCompInv will panic. It should return a positive number,
+// but can return 0 even with non-zero y because of underflow.
func GammaIncCompInv(a, y float64) float64 {
return cephes.IgamI(a, y)
}

MODIFY
internal/cephes/igami.go
internal/cephes/igami.go
@@ -68,7 +68,9 @@ import (
* Copyright 1984, 1987, 1995 by Stephen L. Moshier
*/
-// IgamI calculates the inverse of complemented incomplete Gamma integral
+// IgamI calculates the inverse of the complement of the incomplete Gamma
+// integral. It should return a positive number, but can return 0 even with
+// non-zero y because of underflow.
func IgamI(a, y0 float64) float64 {
// bound the solution
x0 := math.MaxFloat64
@@ -194,9 +196,5 @@ func IgamI(a, y0 float64) float64 {
}
}
- if x == 0 {
- panic(badParamUnderflow)
- }
-
return x
}

Removing underflow panic from cephes.IgamI