module Numeric.Random.Distribution.Uniform where
import Data.Word
uniform32cc :: [Word32]
-> [Double]
uniform32cc xs = map ((/ 4294967295.0) . fromIntegral) $ xs
uniform32co :: [Word32]
-> [Double]
uniform32co xs = map ((/ 4294967296.0) . fromIntegral) $ xs
uniform32oc :: [Word32]
-> [Double]
uniform32oc xs = filter (/= 0) $ uniform32cc $ xs
uniform32oo :: [Word32]
-> [Double]
uniform32oo xs = filter (/= 1) $ uniform32oc $ xs
uniform53cc :: [Word32]
-> [Double]
uniform53cc xs = uniform' xs
where uniform' (u1:u2:us) = (a * 67108864.0 + b) / 9007199254740991.0 : uniform' us
where a = fromIntegral u1 / 32.0
b = fromIntegral u2 / 64.0
uniform' _ = error "uniform53cc: input list must be infinite"
uniform53co :: [Word32]
-> [Double]
uniform53co xs = uniform' $ xs
where uniform' (u1:u2:us) = (a * 67108864.0 + b) / 9007199254740992.0 : uniform' us
where a = fromIntegral u1 / 32.0
b = fromIntegral u2 / 64.0
uniform' _ = error "uniform53co: input list must be infinite"
uniform53oc :: [Word32]
-> [Double]
uniform53oc xs = filter (/= 0) $ uniform53cc $ xs
uniform53oo :: [Word32]
-> [Double]
uniform53oo xs = filter (/= 1) $ uniform53oc $ xs
uniform :: Double
-> Double
-> [Double]
-> [Double]
uniform a b us = map (\u -> (ba)*u + a) us