random is:package
Pseudo-random number generation
This package provides basic pseudo-random number generation, including
the ability to split random number generators.
System.Random: pure pseudo-random number interface
In pure code, use
System.Random.uniform and
System.Random.uniformR from
System.Random to generate
pseudo-random numbers with a pure pseudo-random number generator like
System.Random.StdGen.
As an example, here is how you can simulate rolls of a six-sided die
using
System.Random.uniformR:
>>> let roll = uniformR (1, 6) :: RandomGen g => g -> (Word, g)
>>> let rolls = unfoldr (Just . roll) :: RandomGen g => g -> [Word]
>>> let pureGen = mkStdGen 42
>>> take 10 (rolls pureGen) :: [Word]
[1,1,3,2,4,5,3,4,6,2]
See
System.Random for more details.
In monadic code, use
System.Random.Stateful.uniformM and
System.Random.Stateful.uniformRM from
System.Random.Stateful to generate pseudo-random numbers with a
monadic pseudo-random number generator, or using a monadic adapter.
As an example, here is how you can simulate rolls of a six-sided die
using
System.Random.Stateful.uniformRM:
>>> let rollM = uniformRM (1, 6) :: StatefulGen g m => g -> m Word
>>> let pureGen = mkStdGen 42
>>> runStateGen_ pureGen (replicateM 10 . rollM) :: [Word]
[1,1,3,2,4,5,3,4,6,2]
The monadic adapter
System.Random.Stateful.runStateGen_ is used
here to lift the pure pseudo-random number generator
pureGen
into the
System.Random.Stateful.StatefulGen context.
The monadic interface can also be used with existing monadic
pseudo-random number generators. In this example, we use the one
provided in the
mwc-random package:
>>> import System.Random.MWC as MWC
>>> let rollM = uniformRM (1, 6) :: StatefulGen g m => g -> m Word
>>> monadicGen <- MWC.create
>>> replicateM 10 (rollM monadicGen) :: IO [Word]
[2,3,6,6,4,4,3,1,5,4]
See
System.Random.Stateful for more details.
Random shuffle implementation.
Random shuffle implementation, on immutable lists. Based on `perfect
shuffle' implementation by Oleg Kiselyov, available on
http:okmij.orgftpHaskell/perfect-shuffle.txt
Random number generation
Random number generation based on modeling random variables in two
complementary ways: first, by the parameters of standard mathematical
distributions and, second, by an abstract type (
RVar) which can
be composed and manipulated monadically and sampled in either monadic
or "pure" styles.
The primary purpose of this library is to support defining and
sampling a wide variety of high quality random variables. Quality is
prioritized over speed, but performance is an important goal too.
In my testing, I have found it capable of speed comparable to other
Haskell libraries, but still a fair bit slower than straight C
implementations of the same algorithms.
Not on Stackage, so not searched.
Generic basis for random number generators
Not on Stackage, so not searched.
Generate random strings with specific qualities
Efficient generation of random bytestrings
This package is deprecated. Please, use
genByteString
from the
random package (version >=1.2) instead.
Efficient generation of random bytestrings. The implementation
populates uninitialized memory with uniformily distributed random 64
bit words (and 8 bit words for remaining bytes at the end of the
bytestring).
Random words are generated using the PRNG from the
mwc-random
package or the
pcg-random package. It is also possible to use a
custom PRNG by providing an instance for the
RandomWords type
class and using the function
generate from the module
Data.ByteString.Random.Internal.
The generated byte strings are suitable for statistical applications.
They are
not suitable for cryptographic applications.
Not on Stackage, so not searched.
Additional functions for random values.
Not on Stackage, so not searched.
Random file access methods, supporting application-level page cache.
Not on Stackage, so not searched.
Multivariate distributions for random-fu
Not on Stackage, so not searched.
Random-access lists in Haskell
Not on Stackage, so not searched.
Class of random value generation
Not on Stackage, so not searched.
Uniform draws of partitions and cycle-partitions, with thinning.
Not on Stackage, so not searched.
A Template Haskell helper for deriving Random instances
Not on Stackage, so not searched.
A simple random generator library for extensible-effects
Not on Stackage, so not searched.
A simple random generator library for effin
Not on Stackage, so not searched.
Random variate generation from hypergeometric distributions
Not on Stackage, so not searched.
Expose Random and Arbitrary instances
Not on Stackage, so not searched.
An infinite stream of random data
Not on Stackage, so not searched.
Generate a random base 16, 58, or 64 string
Create random trees
Create random trees
Not on Stackage, so not searched.
"Uniform RNG => Non-Uniform RNGs"
Not on Stackage, so not searched.
A fast, SMP parallel random data generator
Not on Stackage, so not searched.
Haskell port of Random123 library
Not on Stackage, so not searched.
Haskell bindings to the RANDOM.ORG Core API
Not on Stackage, so not searched.
Randomness intuition trainer