Aleksey Khudyakov avatar Aleksey Khudyakov committed bf58f61

Apply same change for CDF test

Comments (0)

Files changed (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
     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]
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.