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 #

With a source of random number supply in hand, the Random class allows the programmer to extract random values of a variety of types.

Minimal complete definition: randomR and random.

Minimal complete definition

randomR, random

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 #

randomRIO :: (Bool, Bool) -> IO Bool Source #

randomIO :: IO 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 #

randomRIO :: (Char, Char) -> IO Char Source #

randomIO :: IO Char Source #

Random Double 
Instance details

Defined in System.Random

Random Float 
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 #

randomRIO :: (Float, Float) -> IO Float Source #

randomIO :: IO 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 #

randomRIO :: (Int, Int) -> IO Int Source #

randomIO :: IO 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 #

randomRIO :: (Int8, Int8) -> IO Int8 Source #

randomIO :: IO 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 #

randomRIO :: (Int16, Int16) -> IO Int16 Source #

randomIO :: IO 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 #

randomRIO :: (Int32, Int32) -> IO Int32 Source #

randomIO :: IO 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 #

randomRIO :: (Int64, Int64) -> IO Int64 Source #

randomIO :: IO Int64 Source #

Random Integer 
Instance details

Defined in System.Random

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 #

randomRIO :: (Word, Word) -> IO Word Source #

randomIO :: IO 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 #

randomRIO :: (Word8, Word8) -> IO Word8 Source #

randomIO :: IO Word8 Source #

Random Word16 
Instance details

Defined in System.Random

Random Word32 
Instance details

Defined in System.Random

Random Word64 
Instance details

Defined in System.Random

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 #

randomRIO :: (CChar, CChar) -> IO CChar Source #

randomIO :: IO CChar Source #

Random CSChar 
Instance details

Defined in System.Random

Random CUChar 
Instance details

Defined in System.Random

Random CShort 
Instance details

Defined in System.Random

Random CUShort 
Instance details

Defined in System.Random

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 #

randomRIO :: (CInt, CInt) -> IO CInt Source #

randomIO :: IO 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 #

randomRIO :: (CUInt, CUInt) -> IO CUInt Source #

randomIO :: IO 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 #

randomRIO :: (CLong, CLong) -> IO CLong Source #

randomIO :: IO CLong Source #

Random CULong 
Instance details

Defined in System.Random

Random CLLong 
Instance details

Defined in System.Random

Random CULLong 
Instance details

Defined in System.Random

Random CFloat 
Instance details

Defined in System.Random

Random CDouble 
Instance details

Defined in System.Random

Random CPtrdiff 
Instance details

Defined in System.Random

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 #

randomRIO :: (CSize, CSize) -> IO CSize Source #

randomIO :: IO CSize Source #

Random CWchar 
Instance details

Defined in System.Random

Random CSigAtomic 
Instance details

Defined in System.Random

Random CIntPtr 
Instance details

Defined in System.Random

Random CUIntPtr 
Instance details

Defined in System.Random

Random CIntMax 
Instance details

Defined in System.Random

Random CUIntMax 
Instance details

Defined in System.Random

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