Safe Haskell | None |
---|---|
Language | Haskell98 |
Moo.GeneticAlgorithm.Random
Synopsis
- getRandomR :: Random a => (a, a) -> Rand a
- getRandom :: Random a => Rand a
- getNormal2 :: Rand (Double, Double)
- getNormal :: Rand Double
- randomSample :: Int -> [a] -> Rand [a]
- randomSampleIndices :: Int -> Int -> Rand [Int]
- shuffle :: [a] -> Rand [a]
- withProbability :: Double -> (a -> Rand a) -> a -> Rand a
- getBool :: Rand Bool
- getInt :: Rand Int
- getWord :: Rand Word
- getInt64 :: Rand Int64
- getWord64 :: Rand Word64
- getDouble :: Rand Double
- runRand :: Rand g a -> g -> (a, g)
- evalRand :: Rand g a -> g -> a
- newPureMT :: IO PureMT
- liftRand :: (g -> (a, g)) -> Rand g a
- type Rand = Rand PureMT
- class Random a
- data PureMT
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
.
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
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
.)
Arguments
:: Rand g a | generator-passing computation to execute |
-> g | initial generator |
-> a | return value of the random computation |
newPureMT :: IO PureMT Source #
Create a new PureMT generator, using the clocktime as the base for the seed.
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
.)
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
Random Bool | |
Random Char | |
Random Double | Note - |
Random Float | Note - |
Random Int | |
Random Int8 | |
Random Int16 | |
Random Int32 | |
Random Int64 | |
Random Integer | |
Random Word | |
Random Word8 | |
Random Word16 | |
Random Word32 | |
Random Word64 | |
Random CChar | |
Random CSChar | |
Random CUChar | |
Random CShort | |
Random CUShort | |
Random CInt | |
Random CUInt | |
Random CLong | |
Random CULong | |
Random CLLong | |
Random CULLong | |
Random CBool | |
Random CFloat | Note - |
Random CDouble | Note - |
Random CPtrdiff | |
Random CSize | |
Random CWchar | |
Random CSigAtomic | |
Defined in System.Random Methods randomR :: RandomGen g => (CSigAtomic, CSigAtomic) -> g -> (CSigAtomic, g) Source # random :: RandomGen g => g -> (CSigAtomic, g) Source # randomRs :: RandomGen g => (CSigAtomic, CSigAtomic) -> g -> [CSigAtomic] Source # randoms :: RandomGen g => g -> [CSigAtomic] Source # | |
Random CIntPtr | |
Random CUIntPtr | |
Random CIntMax | |
Random CUIntMax | |
(Random a, Random b) => Random (a, b) | Note - |
(Random a, Random b, Random c) => Random (a, b, c) | Note - |
(Random a, Random b, Random c, Random d) => Random (a, b, c, d) | Note - |
Defined in System.Random | |
(Random a, Random b, Random c, Random d, Random e) => Random (a, b, c, d, e) | Note - |
(Random a, Random b, Random c, Random d, Random e, Random f) => Random (a, b, c, d, e, f) | Note - |
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 - |
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 # |