Description
Generic basis for random number generators.
Description
Random number generation based on entropy sources able to produce a small but well-defined set of primitive variates. Also includes facilities for "completing" partial implementations, making it easy to define new entropy sources in a way that is naturally forward-compatible. Now DEPRECATED: see README for further details.
README.md
This is now deprecated and it is better to use the random package as the source of randomness.
Here's what you might have written before:
import qualified Data.Random as Random
import qualified Data.Random.Distribution.Bernoulli as Bernoulli
main :: IO ()
main = do
x <- Random.sample $ Bernoulli.Bernoulli (0.5 :: Double) :: IO Double
print x
And here's what you should write now (but there are many other options):
import qualified System.Random.Stateful as Random.Stateful
import qualified Data.Random as Random
import qualified Data.Random.Distribution.Bernoulli as Bernoulli
import qualified Control.Monad.Reader as Reader
main :: IO ()
main = do
stdgen <- Random.Stateful.newIOGenM =<< Random.Stateful.newStdGen
x <- Reader.runReaderT (Random.sample $ Bernoulli.Bernoulli (0.5 :: Double)) stdgen
:: IO Double
print x