| Safe Haskell | None |
|---|---|
| Language | Haskell98 |
Autolib.Util.RandoM
Documentation
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
Minimal complete definition
Nothing
Methods
randomR :: RandomGen g => (a, a) -> g -> (a, g) #
Takes a range (lo,hi) and a pseudo-random number generator g, and returns a pseudo-random value uniformly distributed over the closed interval [lo,hi], together with a new generator. It is unspecified what happens if lo>hi, but usually the values will simply get swapped.
>>>let gen = mkStdGen 26>>>fst $ randomR ('a', 'z') gen'z'>>>fst $ randomR ('a', 'z') gen'z'
For continuous types there is no requirement that the values lo and hi are ever produced, but they may be, depending on the implementation and the interval.
There is no requirement to follow the Ord instance and the concept of range can be
defined on per type basis. For example product types will treat their values
independently:
>>>fst $ randomR (('a', 5.0), ('z', 10.0)) $ mkStdGen 26('z',5.22694980853051)
In case when a lawful range is desired uniformR should be used
instead.
Since: random-1.0.0
default randomR :: (RandomGen g, UniformRange a) => (a, a) -> g -> (a, g) #
random :: RandomGen g => g -> (a, g) #
The same as randomR, but using a default range determined by the type:
- For bounded types (instances of
Bounded, such asChar), the range is normally the whole type. - For floating point types, the range is normally the closed interval
[0,1]. - For
Integer, the range is (arbitrarily) the range ofInt.
Since: random-1.0.0
randomRs :: RandomGen g => (a, a) -> g -> [a] #
Plural variant of randomR, producing an infinite list of
pseudo-random values instead of returning a new generator.
Since: random-1.0.0
randoms :: RandomGen g => g -> [a] #
Plural variant of random, producing an infinite list of
pseudo-random values instead of returning a new generator.
Since: random-1.0.0
Instances
| Random Nat Source # | |
| Random Pos Source # | |
| Random CBool # | |
| Random CChar # | |
| Random CDouble # | Note - |
| Random CFloat # | Note - |
| Random CInt # | |
| Random CIntMax # | |
| Random CIntPtr # | |
| Random CLLong # | |
| Random CLong # | |
| Random CPtrdiff # | |
| Random CSChar # | |
| Random CShort # | |
| Random CSigAtomic # | |
Defined in System.Random Methods randomR :: RandomGen g => (CSigAtomic, CSigAtomic) -> g -> (CSigAtomic, g) # random :: RandomGen g => g -> (CSigAtomic, g) # randomRs :: RandomGen g => (CSigAtomic, CSigAtomic) -> g -> [CSigAtomic] # randoms :: RandomGen g => g -> [CSigAtomic] # | |
| Random CSize # | |
| Random CUChar # | |
| Random CUInt # | |
| Random CUIntMax # | |
| Random CUIntPtr # | |
| Random CULLong # | |
| Random CULong # | |
| Random CUShort # | |
| Random CWchar # | |
| Random Int16 # | |
| Random Int32 # | |
| Random Int64 # | |
| Random Int8 # | |
| Random Word16 # | |
| Random Word32 # | |
| Random Word64 # | |
| Random Word8 # | |
| Random Integer # | |
| Random Bool # | |
| Random Char # | |
| Random Double # | Note - |
| Random Float # | Note - |
| Random Int # | |
| Random Word # | |
| (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 - |
| (Random a, Random b, Random c, Random d, Random e) => Random (a, b, c, d, e) # | Note - |
Defined in System.Random | |
| (Random a, Random b, Random c, Random d, Random e, Random f) => Random (a, b, c, d, e, f) # | Note - |
| (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 | |