Skip to content

Commit

Permalink
Avoid underflow in invIncompleteGamma
Browse files Browse the repository at this point in the history
Uderflow occurs in calculation of  inital approximation
if a*a = 0 then log(a*a) = -∞ and everything goes awry from this point
  • Loading branch information
Shimuuar committed Oct 3, 2012
1 parent 104816d commit 1db1cff
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Numeric/SpecFunctions.hs
Expand Up @@ -447,7 +447,7 @@ invIncompleteBetaWorker beta p q a = loop (0::Int) guess
| t'' <= 1 = exp( (log(a * p) + beta) / p )
| otherwise = 1 - 2 / (t'' + 1)
where
r = sqrt ( - log ( a * a ) )
r = sqrt $ - 2 * log a
y = r - ( 2.30753 + 0.27061 * r )
/ ( 1.0 + ( 0.99229 + 0.04481 * r ) * r )
t = 1 / (9 * q)
Expand Down

0 comments on commit 1db1cff

Please sign in to comment.