moo-1.2: Genetic algorithm library
Safe HaskellNone
LanguageHaskell98

Moo.GeneticAlgorithm.Random

Description

Some extra facilities to work with Rand monad and PureMT random number generator.

Synopsis

Random numbers from given range

getRandomR :: Random a => (a, a) -> Rand a Source #

Yield a new randomly selected value of type a in the range (lo, hi). See randomR for details.

getRandom :: Random a => Rand a Source #

Yield a new randomly selected value of type a. See random for details.

Probability distributions

getNormal2 :: Rand (Double, Double) Source #

Yield two randomly selected values which follow standard normal distribution.

getNormal :: Rand Double Source #

Yield one randomly selected value from standard normal distribution.

Random samples and shuffles

randomSample :: Int -> [a] -> Rand [a] Source #

Take at most n random elements from the list. Preserve order.

randomSampleIndices :: Int -> Int -> Rand [Int] Source #

Select sampleSize numbers in the range from 0 to (populationSize-1). The function works best when sampleSize is much smaller than populationSize.

shuffle :: [a] -> Rand [a] Source #

Randomly reorder the list.

Building blocks

withProbability :: Double -> (a -> Rand a) -> a -> Rand a Source #

Modify value with probability p. Return the unchanged value with probability 1-p.

Re-exports from random number generator packages

runRand Source #

Arguments

:: Rand g a

generator-passing computation to execute

-> g

initial generator

-> (a, g)

return value and final generator

Unwrap a random monad computation as a function. (The inverse of liftRand.)

evalRand Source #

Arguments

:: Rand g a

generator-passing computation to execute

-> g

initial generator

-> a

return value of the random computation

Evaluate a random computation with the given initial generator and return the final value, discarding the final generator.

newPureMT :: IO PureMT Source #

Create a new PureMT generator, using the clocktime as the base for the seed.

liftRand Source #

Arguments

:: (g -> (a, g))

pure random transformer

-> Rand g a

equivalent generator-passing computation

Construct a random monad computation from a function. (The inverse of runRand.)

class Random a Source #

The class of types for which random values can be generated. Most instances of Random will produce values that are uniformly distributed on the full range, but for those types without a well-defined "full range" some sensible default subrange will be selected.

Random exists primarily for backwards compatibility with version 1.1 of this library. In new code, use the better specified Uniform and UniformRange instead.

Since: random-1.0.0

Instances

Instances details
Random Bool 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (Bool, Bool) -> g -> (Bool, g) Source #

random :: RandomGen g => g -> (Bool, g) Source #

randomRs :: RandomGen g => (Bool, Bool) -> g -> [Bool] Source #

randoms :: RandomGen g => g -> [Bool] Source #

Random Char 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (Char, Char) -> g -> (Char, g) Source #

random :: RandomGen g => g -> (Char, g) Source #

randomRs :: RandomGen g => (Char, Char) -> g -> [Char] Source #

randoms :: RandomGen g => g -> [Char] Source #

Random Double

Note - random produces values in the closed range [0,1].

Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (Double, Double) -> g -> (Double, g) Source #

random :: RandomGen g => g -> (Double, g) Source #

randomRs :: RandomGen g => (Double, Double) -> g -> [Double] Source #

randoms :: RandomGen g => g -> [Double] Source #

Random Float

Note - random produces values in the closed range [0,1].

Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (Float, Float) -> g -> (Float, g) Source #

random :: RandomGen g => g -> (Float, g) Source #

randomRs :: RandomGen g => (Float, Float) -> g -> [Float] Source #

randoms :: RandomGen g => g -> [Float] Source #

Random Int 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (Int, Int) -> g -> (Int, g) Source #

random :: RandomGen g => g -> (Int, g) Source #

randomRs :: RandomGen g => (Int, Int) -> g -> [Int] Source #

randoms :: RandomGen g => g -> [Int] Source #

Random Int8 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (Int8, Int8) -> g -> (Int8, g) Source #

random :: RandomGen g => g -> (Int8, g) Source #

randomRs :: RandomGen g => (Int8, Int8) -> g -> [Int8] Source #

randoms :: RandomGen g => g -> [Int8] Source #

Random Int16 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (Int16, Int16) -> g -> (Int16, g) Source #

random :: RandomGen g => g -> (Int16, g) Source #

randomRs :: RandomGen g => (Int16, Int16) -> g -> [Int16] Source #

randoms :: RandomGen g => g -> [Int16] Source #

Random Int32 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (Int32, Int32) -> g -> (Int32, g) Source #

random :: RandomGen g => g -> (Int32, g) Source #

randomRs :: RandomGen g => (Int32, Int32) -> g -> [Int32] Source #

randoms :: RandomGen g => g -> [Int32] Source #

Random Int64 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (Int64, Int64) -> g -> (Int64, g) Source #

random :: RandomGen g => g -> (Int64, g) Source #

randomRs :: RandomGen g => (Int64, Int64) -> g -> [Int64] Source #

randoms :: RandomGen g => g -> [Int64] Source #

Random Integer

Note - random generates values in the Int range

Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (Integer, Integer) -> g -> (Integer, g) Source #

random :: RandomGen g => g -> (Integer, g) Source #

randomRs :: RandomGen g => (Integer, Integer) -> g -> [Integer] Source #

randoms :: RandomGen g => g -> [Integer] Source #

Random Word 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (Word, Word) -> g -> (Word, g) Source #

random :: RandomGen g => g -> (Word, g) Source #

randomRs :: RandomGen g => (Word, Word) -> g -> [Word] Source #

randoms :: RandomGen g => g -> [Word] Source #

Random Word8 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (Word8, Word8) -> g -> (Word8, g) Source #

random :: RandomGen g => g -> (Word8, g) Source #

randomRs :: RandomGen g => (Word8, Word8) -> g -> [Word8] Source #

randoms :: RandomGen g => g -> [Word8] Source #

Random Word16 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (Word16, Word16) -> g -> (Word16, g) Source #

random :: RandomGen g => g -> (Word16, g) Source #

randomRs :: RandomGen g => (Word16, Word16) -> g -> [Word16] Source #

randoms :: RandomGen g => g -> [Word16] Source #

Random Word32 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (Word32, Word32) -> g -> (Word32, g) Source #

random :: RandomGen g => g -> (Word32, g) Source #

randomRs :: RandomGen g => (Word32, Word32) -> g -> [Word32] Source #

randoms :: RandomGen g => g -> [Word32] Source #

Random Word64 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (Word64, Word64) -> g -> (Word64, g) Source #

random :: RandomGen g => g -> (Word64, g) Source #

randomRs :: RandomGen g => (Word64, Word64) -> g -> [Word64] Source #

randoms :: RandomGen g => g -> [Word64] Source #

Random CChar 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CChar, CChar) -> g -> (CChar, g) Source #

random :: RandomGen g => g -> (CChar, g) Source #

randomRs :: RandomGen g => (CChar, CChar) -> g -> [CChar] Source #

randoms :: RandomGen g => g -> [CChar] Source #

Random CSChar 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CSChar, CSChar) -> g -> (CSChar, g) Source #

random :: RandomGen g => g -> (CSChar, g) Source #

randomRs :: RandomGen g => (CSChar, CSChar) -> g -> [CSChar] Source #

randoms :: RandomGen g => g -> [CSChar] Source #

Random CUChar 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CUChar, CUChar) -> g -> (CUChar, g) Source #

random :: RandomGen g => g -> (CUChar, g) Source #

randomRs :: RandomGen g => (CUChar, CUChar) -> g -> [CUChar] Source #

randoms :: RandomGen g => g -> [CUChar] Source #

Random CShort 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CShort, CShort) -> g -> (CShort, g) Source #

random :: RandomGen g => g -> (CShort, g) Source #

randomRs :: RandomGen g => (CShort, CShort) -> g -> [CShort] Source #

randoms :: RandomGen g => g -> [CShort] Source #

Random CUShort 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CUShort, CUShort) -> g -> (CUShort, g) Source #

random :: RandomGen g => g -> (CUShort, g) Source #

randomRs :: RandomGen g => (CUShort, CUShort) -> g -> [CUShort] Source #

randoms :: RandomGen g => g -> [CUShort] Source #

Random CInt 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CInt, CInt) -> g -> (CInt, g) Source #

random :: RandomGen g => g -> (CInt, g) Source #

randomRs :: RandomGen g => (CInt, CInt) -> g -> [CInt] Source #

randoms :: RandomGen g => g -> [CInt] Source #

Random CUInt 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CUInt, CUInt) -> g -> (CUInt, g) Source #

random :: RandomGen g => g -> (CUInt, g) Source #

randomRs :: RandomGen g => (CUInt, CUInt) -> g -> [CUInt] Source #

randoms :: RandomGen g => g -> [CUInt] Source #

Random CLong 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CLong, CLong) -> g -> (CLong, g) Source #

random :: RandomGen g => g -> (CLong, g) Source #

randomRs :: RandomGen g => (CLong, CLong) -> g -> [CLong] Source #

randoms :: RandomGen g => g -> [CLong] Source #

Random CULong 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CULong, CULong) -> g -> (CULong, g) Source #

random :: RandomGen g => g -> (CULong, g) Source #

randomRs :: RandomGen g => (CULong, CULong) -> g -> [CULong] Source #

randoms :: RandomGen g => g -> [CULong] Source #

Random CLLong 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CLLong, CLLong) -> g -> (CLLong, g) Source #

random :: RandomGen g => g -> (CLLong, g) Source #

randomRs :: RandomGen g => (CLLong, CLLong) -> g -> [CLLong] Source #

randoms :: RandomGen g => g -> [CLLong] Source #

Random CULLong 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CULLong, CULLong) -> g -> (CULLong, g) Source #

random :: RandomGen g => g -> (CULLong, g) Source #

randomRs :: RandomGen g => (CULLong, CULLong) -> g -> [CULLong] Source #

randoms :: RandomGen g => g -> [CULLong] Source #

Random CBool 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CBool, CBool) -> g -> (CBool, g) Source #

random :: RandomGen g => g -> (CBool, g) Source #

randomRs :: RandomGen g => (CBool, CBool) -> g -> [CBool] Source #

randoms :: RandomGen g => g -> [CBool] Source #

Random CFloat

Note - random produces values in the closed range [0,1].

Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CFloat, CFloat) -> g -> (CFloat, g) Source #

random :: RandomGen g => g -> (CFloat, g) Source #

randomRs :: RandomGen g => (CFloat, CFloat) -> g -> [CFloat] Source #

randoms :: RandomGen g => g -> [CFloat] Source #

Random CDouble

Note - random produces values in the closed range [0,1].

Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CDouble, CDouble) -> g -> (CDouble, g) Source #

random :: RandomGen g => g -> (CDouble, g) Source #

randomRs :: RandomGen g => (CDouble, CDouble) -> g -> [CDouble] Source #

randoms :: RandomGen g => g -> [CDouble] Source #

Random CPtrdiff 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CPtrdiff, CPtrdiff) -> g -> (CPtrdiff, g) Source #

random :: RandomGen g => g -> (CPtrdiff, g) Source #

randomRs :: RandomGen g => (CPtrdiff, CPtrdiff) -> g -> [CPtrdiff] Source #

randoms :: RandomGen g => g -> [CPtrdiff] Source #

Random CSize 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CSize, CSize) -> g -> (CSize, g) Source #

random :: RandomGen g => g -> (CSize, g) Source #

randomRs :: RandomGen g => (CSize, CSize) -> g -> [CSize] Source #

randoms :: RandomGen g => g -> [CSize] Source #

Random CWchar 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CWchar, CWchar) -> g -> (CWchar, g) Source #

random :: RandomGen g => g -> (CWchar, g) Source #

randomRs :: RandomGen g => (CWchar, CWchar) -> g -> [CWchar] Source #

randoms :: RandomGen g => g -> [CWchar] Source #

Random CSigAtomic 
Instance details

Defined in System.Random

Random CIntPtr 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CIntPtr, CIntPtr) -> g -> (CIntPtr, g) Source #

random :: RandomGen g => g -> (CIntPtr, g) Source #

randomRs :: RandomGen g => (CIntPtr, CIntPtr) -> g -> [CIntPtr] Source #

randoms :: RandomGen g => g -> [CIntPtr] Source #

Random CUIntPtr 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CUIntPtr, CUIntPtr) -> g -> (CUIntPtr, g) Source #

random :: RandomGen g => g -> (CUIntPtr, g) Source #

randomRs :: RandomGen g => (CUIntPtr, CUIntPtr) -> g -> [CUIntPtr] Source #

randoms :: RandomGen g => g -> [CUIntPtr] Source #

Random CIntMax 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CIntMax, CIntMax) -> g -> (CIntMax, g) Source #

random :: RandomGen g => g -> (CIntMax, g) Source #

randomRs :: RandomGen g => (CIntMax, CIntMax) -> g -> [CIntMax] Source #

randoms :: RandomGen g => g -> [CIntMax] Source #

Random CUIntMax 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CUIntMax, CUIntMax) -> g -> (CUIntMax, g) Source #

random :: RandomGen g => g -> (CUIntMax, g) Source #

randomRs :: RandomGen g => (CUIntMax, CUIntMax) -> g -> [CUIntMax] Source #

randoms :: RandomGen g => g -> [CUIntMax] Source #

(Random a, Random b) => Random (a, b)

Note - randomR treats a and b types independently

Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => ((a, b), (a, b)) -> g -> ((a, b), g) Source #

random :: RandomGen g => g -> ((a, b), g) Source #

randomRs :: RandomGen g => ((a, b), (a, b)) -> g -> [(a, b)] Source #

randoms :: RandomGen g => g -> [(a, b)] Source #

(Random a, Random b, Random c) => Random (a, b, c)

Note - randomR treats a, b and c types independently

Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => ((a, b, c), (a, b, c)) -> g -> ((a, b, c), g) Source #

random :: RandomGen g => g -> ((a, b, c), g) Source #

randomRs :: RandomGen g => ((a, b, c), (a, b, c)) -> g -> [(a, b, c)] Source #

randoms :: RandomGen g => g -> [(a, b, c)] Source #

(Random a, Random b, Random c, Random d) => Random (a, b, c, d)

Note - randomR treats a, b, c and d types independently

Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => ((a, b, c, d), (a, b, c, d)) -> g -> ((a, b, c, d), g) Source #

random :: RandomGen g => g -> ((a, b, c, d), g) Source #

randomRs :: RandomGen g => ((a, b, c, d), (a, b, c, d)) -> g -> [(a, b, c, d)] Source #

randoms :: RandomGen g => g -> [(a, b, c, d)] Source #

(Random a, Random b, Random c, Random d, Random e) => Random (a, b, c, d, e)

Note - randomR treats a, b, c, d and e types independently

Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => ((a, b, c, d, e), (a, b, c, d, e)) -> g -> ((a, b, c, d, e), g) Source #

random :: RandomGen g => g -> ((a, b, c, d, e), g) Source #

randomRs :: RandomGen g => ((a, b, c, d, e), (a, b, c, d, e)) -> g -> [(a, b, c, d, e)] Source #

randoms :: RandomGen g => g -> [(a, b, c, d, e)] Source #

(Random a, Random b, Random c, Random d, Random e, Random f) => Random (a, b, c, d, e, f)

Note - randomR treats a, b, c, d, e and f types independently

Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => ((a, b, c, d, e, f), (a, b, c, d, e, f)) -> g -> ((a, b, c, d, e, f), g) Source #

random :: RandomGen g => g -> ((a, b, c, d, e, f), g) Source #

randomRs :: RandomGen g => ((a, b, c, d, e, f), (a, b, c, d, e, f)) -> g -> [(a, b, c, d, e, f)] Source #

randoms :: RandomGen g => g -> [(a, b, c, d, e, f)] Source #

(Random a, Random b, Random c, Random d, Random e, Random f, Random g) => Random (a, b, c, d, e, f, g)

Note - randomR treats a, b, c, d, e, f and g types independently

Instance details

Defined in System.Random

Methods

randomR :: RandomGen g0 => ((a, b, c, d, e, f, g), (a, b, c, d, e, f, g)) -> g0 -> ((a, b, c, d, e, f, g), g0) Source #

random :: RandomGen g0 => g0 -> ((a, b, c, d, e, f, g), g0) Source #

randomRs :: RandomGen g0 => ((a, b, c, d, e, f, g), (a, b, c, d, e, f, g)) -> g0 -> [(a, b, c, d, e, f, g)] Source #

randoms :: RandomGen g0 => g0 -> [(a, b, c, d, e, f, g)] Source #

data PureMT Source #

PureMT, a pure mersenne twister pseudo-random number generator

Instances

Instances details
Show PureMT 
Instance details

Defined in System.Random.Mersenne.Pure64.Internal