Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
This module provides functions to generate random numbers using balanced integer tables randomized by the RealDice data or custom integer tables
Documentation
Stores a balanced table of random integers and an index pointing to the next value to return
randomIntR :: (Int, Int) -> RDGen -> (Int, RDGen) Source #
Generates a random integer value between minResult and maxResult via a simple table lookup
Examples
>>>
randomIntR (1, 20) (mkRDGen 143)
(12, {144, rdIntsPrime})>>>
randomIntR (-1000000, 1000000) (mkRDGen 42)
(76465, {43, rdIntsPrime})>>>
randomIntR (10, 1) (mkRDGen 42)
(0, {43, rdIntsPrime})
randomFloat :: Int -> RDGen -> (Float, RDGen) Source #
Examples
>>>
randomFloat 3 (mkRDGen 143)
(0.503, {144, rdIntsPrime})>>>
randomFloat 0 (mkRDGen 143)
(0, {143, rdIntsPrime})>>>
randomFloat (-1) (mkRDGen 143)
(0, {143, rdIntsPrime})
randomDouble :: Int -> RDGen -> (Double, RDGen) Source #
Examples
>>>
randomDouble 3 (mkRDGen 143)
(0.503, {144, rdIntsPrime})>>>
randomDouble 0 (mkRDGen 143)
(0, {143, rdIntsPrime})>>>
randomDouble (-1) (mkRDGen 143)
(0, {143, rdIntsPrime})