State of the random number generator
Modulepcg-random-0.1.4.0Haskell2010
System.Random.PCG.Unique
Unique variant of the PCG random number generator. Guarantees the sequence to be unique by using the pointer address to select the output sequence.
There is no way to freeze the state because then it wouldn't be unique anymore. Also, generators can't be initialized in ST because we don't know what pointer reference they'll get.
See http://www.pcg-random.org for details.
import System.Random.PCG.Unique
three :: IO [Double]
three = do
g <- create
a <- uniform g
b <- uniform g
c <- uniform g
return [a,b,c]
- 1 type
- 1 class
- 39 values
- Packagepcg-random-0.1.4.0
- Exports41
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceUnique.hs
Gen
5 declarationsCreate a Gen from a fixed initial seed.
Seed a PRNG with data from the system's fast source of pseudo-random numbers. All the caveats of withSystemRandom apply here as well.
Create a generator from two words. Note: this is not the same as the
two words in a Seed.
Seed with system random number. ("/dev/urandom" on Unix-like
systems, time otherwise).
Getting random numbers
3 declarationsMethods
uniform :: Generator g m => g -> m aGenerate a uniformly distributed random vairate.
Use entire range for integral types.
Use (0,1] range for floating types.
uniformR :: Generator g m => (a, a) -> g -> m aGenerate a uniformly distributed random vairate in the given range.
Use inclusive range for integral types.
Use (a,b] range for floating types.
uniformB :: Generator g m => a -> g -> m aGenerate a uniformly distributed random vairate in the range [0,b). For integral types the bound must be less than the max bound of Word32 (4294967295). Behaviour is undefined for negative bounds.
Instances16Variate, …
Variate Int16Defined in pcg-random-0.1.4.0 · System.Random.PCG.ClassVariate Int32Defined in pcg-random-0.1.4.0 · System.Random.PCG.ClassVariate Int64Defined in pcg-random-0.1.4.0 · System.Random.PCG.ClassVariate Int8Defined in pcg-random-0.1.4.0 · System.Random.PCG.ClassVariate Word16Defined in pcg-random-0.1.4.0 · System.Random.PCG.ClassVariate Word32Defined in pcg-random-0.1.4.0 · System.Random.PCG.ClassVariate Word64Defined in pcg-random-0.1.4.0 · System.Random.PCG.ClassVariate Word8Defined in pcg-random-0.1.4.0 · System.Random.PCG.ClassVariate BoolDefined in pcg-random-0.1.4.0 · System.Random.PCG.ClassVariate DoubleDefined in pcg-random-0.1.4.0 · System.Random.PCG.ClassVariate FloatDefined in pcg-random-0.1.4.0 · System.Random.PCG.ClassVariate IntDefined in pcg-random-0.1.4.0 · System.Random.PCG.ClassVariate WordDefined in pcg-random-0.1.4.0 · System.Random.PCG.Class(Variate a, Variate b) => Variate (a, b)Defined in pcg-random-0.1.4.0 · System.Random.PCG.Class(Variate a, Variate b, Variate c) => Variate (a, b, c)Defined in pcg-random-0.1.4.0 · System.Random.PCG.Class(Variate a, Variate b, Variate c, Variate d) => Variate (a, b, c, d)Defined in pcg-random-0.1.4.0 · System.Random.PCG.Class
Advance the given generator n steps in log(n) time.
Retract the given generator n steps in log(2^64-n) time. This
is just advance (-n).