aboutsummaryrefslogtreecommitdiff
path: root/src/PPL
diff options
context:
space:
mode:
Diffstat (limited to 'src/PPL')
-rw-r--r--src/PPL/Distr.hs4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/PPL/Distr.hs b/src/PPL/Distr.hs
index e1fd5aa..8ffbd0f 100644
--- a/src/PPL/Distr.hs
+++ b/src/PPL/Distr.hs
@@ -95,7 +95,9 @@ geom p = first 0 <$> iid (bern p)
first _ _ = undefined
bounded :: Double -> Double -> Prob Double
-bounded lower upper = (+ lower) . (* (upper - lower)) <$> uniform
+bounded lower upper = do
+ z <- uniform
+ pure $ 2 * (lower / 2 + (upper / 2 - lower / 2) * z)
bounded' :: Integral a => a -> a -> Prob a
bounded' lower upper = round <$> bounded (fromIntegral lower) (fromIntegral upper)