Skip to content

Commit

Permalink
Test that incompleteBeta is in range
Browse files Browse the repository at this point in the history
  • Loading branch information
Shimuuar committed Jan 27, 2012
1 parent cd0f039 commit 6646f80
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/Tests/SpecFunctions.hs
Expand Up @@ -25,6 +25,7 @@ tests = testGroup "Special functions"
, testProperty "γ - increases" $
\s x y -> s > 0 && x > 0 && y > 0 ==> monotonicallyIncreases (incompleteGamma s) x y
, testProperty "invIncompleteGamma = γ^-1" $ invIGammaIsInverse
, testProperty "0 <= I[B] <= 1" $ incompleteBetaInRange
, testProperty "invIncompleteBeta = B^-1" $ invIBetaIsInverse
-- Unit tests
, testAssertion "Factorial is expected to be precise at 1e-15 level"
Expand Down Expand Up @@ -97,6 +98,11 @@ invIGammaIsInverse (abs -> a) (abs . snd . properFraction -> p) =
x = invIncompleteGamma a p
p' = incompleteGamma a x

-- B(s,x) is in [0,1] range
incompleteBetaInRange :: Double -> Double -> Double -> Property
incompleteBetaInRange (abs -> p) (abs -> q) (abs . snd . properFraction -> x) =
p > 0 && q > 0 ==> let i = incompleteBeta p q x in i >= 0 && i <= 1

-- invIncompleteBeta is inverse of incompleteBeta
invIBetaIsInverse :: Double -> Double -> Double -> Property
invIBetaIsInverse (abs -> p) (abs -> q) (abs . snd . properFraction -> x) =
Expand Down

0 comments on commit 6646f80

Please sign in to comment.