Permalink
Browse files

Fix edge case for F distribution

Following should hold:
> cumulative d +Infinity = 1
  • Loading branch information...
1 parent 8d9bf87 commit 7e06a4d742a1276dca4d562057ff1c1fe3505596 @Shimuuar Shimuuar committed Sep 8, 2012
Showing with 3 additions and 2 deletions.
  1. +3 −2 Statistics/Distribution/FDistribution.hs
@@ -49,8 +49,9 @@ instance D.ContDistr FDistribution where
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

0 comments on commit 7e06a4d

Please sign in to comment.