-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A fast, pseudorandom number generator. -- -- A fast pseudorandom number generator, as presented by M.E. O'Neill on -- http://www.pcg-random.org, See that site for information on the -- particulars of the technique used. This particular implementation uses -- two Word64 of internal data and produces a Word32 of output per step. -- On 64-bit machines it's two to three times as fast as StdGen and uses -- the same amount of space. @package pcgen @version 2.0.1 -- | This module contains a permuted linear congruential pseudorandom -- number generator, as described by M.E. O'Neill -- (pcg-random.org). This version holds two Word64 values -- and outputs a Word32 of randomness each time you use it. -- Compared to the StdGen type from System.Random, it's -- around a 2.5x to 3x speedup on a 64-bit system. It runs somewhat -- slower than StdGen on a 32-bit system (the Word64 -- values must be emulated after all), but there aren't too many of those -- in play these days anyway. Raspberry Pi is the only common thing I can -- think of, which isn't the best for Haskell in the first place. If you -- somehow are using 32-bit all the time I guess this module isn't for -- you. -- -- The first Word64 is the state, which changes with -- each step of the generator. The second Word64 is the -- inc, which stays fixed from step to step and controls what -- stream of numbers is generated. The inc is always bitwise -- OR'd with 1 during computations, so there are only 2^63 distinct -- number streams (eg: inc 2 and 3 are the same number stream). -- The state value eventually returns to it's initial value -- after 2^64 uses and the whole sequence loops around. module Data.PCGen -- | The PCGen data type. You can use the constructor yourself -- with two Word64 values, but with human picked seeds the first -- result will generally be 0. To avoid that you can use the -- mkPCGen helper. data PCGen PCGen :: !Word64 -> !Word64 -> PCGen -- | Creates a new PCGen value by using the Integral given as both the -- state and inc values for the generator. The state of -- the generator is then advanced once, because otherwise the first -- result tends to be 0 with human picked seeds. mkPCGen :: Integral i => i -> PCGen -- | Advances the given generator one step, giving back a Word32 -- of output and the resultant generator as well. This is the most basic -- way to advance the generator. You probably want to use the -- RandomGen instance and the next method, along with -- something like MonadRandom stepGen :: PCGen -> (Word32, PCGen) instance GHC.Classes.Ord Data.PCGen.PCGen instance GHC.Classes.Eq Data.PCGen.PCGen instance GHC.Show.Show Data.PCGen.PCGen instance GHC.Read.Read Data.PCGen.PCGen instance System.Random.RandomGen Data.PCGen.PCGen instance System.Random.Random Data.PCGen.PCGen instance Foreign.Storable.Storable Data.PCGen.PCGen