Commits

Aleksey Khudyakov committed d6f5ba3

Fix edge case for F distribution

Following should hold:
> cumulative d +Infinity = 1

Comments (0)

Files changed (1)

Statistics/Distribution/FDistribution.hs

   
 cumulative :: FDistribution -> Double -> Double
 cumulative (F n m _) x
-  | x > 0     = let y = n*x in incompleteBeta (0.5 * n) (0.5 * m) (y / (m + y))
-  | otherwise = 0
+  | x <= 0       = 0
+  | isInfinite x = 1            -- Only matches +∞
+  | x > 0        = let y = n*x in incompleteBeta (0.5 * n) (0.5 * m) (y / (m + y))
 
 density :: FDistribution -> Double -> Double
 density (F n m fac) x