Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Apply same change for CDF test

  • Loading branch information...
commit 3f00a5e21105eed7044bf88929617dfb608bd2f7 1 parent 8470b66
@Shimuuar Shimuuar authored
Showing with 6 additions and 3 deletions.
  1. +6 −3 tests/Tests/Distribution.hs
View
9 tests/Tests/Distribution.hs
@@ -161,15 +161,18 @@ probSanityCheck _ d x = p >= 0 && p <= 1
-- Check that discrete CDF is correct
discreteCDFcorrect :: (DiscreteDistr d) => T d -> d -> Int -> Int -> Property
-discreteCDFcorrect _ d a b =
- abs (a - b) < 100 ==> abs (p1 - p2) < 3e-10
+discreteCDFcorrect _ d a b
+ = printTestCase (printf "CDF = %g" p1)
+ $ printTestCase (printf "Sum = %g" p2)
+ $ printTestCase (printf "Δ = %g" (abs (p1 - p2)))
+ $ abs (p1 - p2) < 3e-10
-- Avoid too large differeneces. Otherwise there is to much to sum
--
-- Absolute difference is used guard againist precision loss when
-- close values of CDF are subtracted
where
n = min a b
- m = max a b
+ m = n + (abs (a - b) `mod` 100)
p1 = cumulative d (fromIntegral m + 0.5) - cumulative d (fromIntegral n - 0.5)
p2 = sum $ map (probability d) [n .. m]
Please sign in to comment.
Something went wrong with that request. Please try again.