Copyright | (c) Antony Courtney and Henrik Nilsson Yale University 2003 |
---|---|
License | BSD-style (see the LICENSE file in the distribution) |
Maintainer | ivan.perez@keera.co.uk |
Stability | provisional |
Portability | non-portable (GHC extensions) |
Safe Haskell | None |
Language | Haskell2010 |
Signals and signal functions with noise and randomness.
The Random number generators are re-exported from System.Random.
Synopsis
- class RandomGen g where
- next :: g -> (Int, g)
- genWord8 :: g -> (Word8, g)
- genWord16 :: g -> (Word16, g)
- genWord32 :: g -> (Word32, g)
- genWord64 :: g -> (Word64, g)
- genWord32R :: Word32 -> g -> (Word32, g)
- genWord64R :: Word64 -> g -> (Word64, g)
- genShortByteString :: Int -> g -> (ShortByteString, g)
- genRange :: g -> (Int, Int)
- split :: g -> (g, g)
- class Random a where
- noise :: (RandomGen g, Random b) => g -> SF a b
- noiseR :: (RandomGen g, Random b) => (b, b) -> g -> SF a b
- occasionally :: RandomGen g => g -> Time -> b -> SF a (Event b)
Random number generators
RandomGen
is an interface to pure pseudo-random number generators.
StdGen
is the standard RandomGen
instance provided by this library.
Returns an Int
that is uniformly distributed over the range returned by
genRange
(including both end points), and a new generator. Using next
is inefficient as all operations go via Integer
. See
here for
more details. It is thus deprecated.
genWord16 :: g -> (Word16, g) #
genWord32 :: g -> (Word32, g) #
genWord64 :: g -> (Word64, g) #
genWord32R :: Word32 -> g -> (Word32, g) #
genWord32R upperBound g
returns a Word32
that is uniformly
distributed over the range [0, upperBound]
.
Since: random-1.2.0
genWord64R :: Word64 -> g -> (Word64, g) #
genWord64R upperBound g
returns a Word64
that is uniformly
distributed over the range [0, upperBound]
.
Since: random-1.2.0
genShortByteString :: Int -> g -> (ShortByteString, g) #
genShortByteString n g
returns a ShortByteString
of length n
filled with pseudo-random bytes.
Since: random-1.2.0
Instances
The class of types for which uniformly distributed values can be generated.
Random
exists primarily for backwards compatibility with version 1.1 of
this library. In new code, use the better specified Uniform
and
UniformRange
instead.
Nothing
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. 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.
random :: RandomGen g => g -> (a, g) #
The same as randomR
, but using a default range determined by the type:
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.
randoms :: RandomGen g => g -> [a] #
Plural variant of random
, producing an infinite list of
pseudo-random values instead of returning a new generator.
Instances
Random Bool | |
Random Char | |
Random Double | |
Random Float | |
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 CFloat | |
Random CDouble | |
Random CPtrdiff | |
Random CSize | |
Random CWchar | |
Random CSigAtomic | |
Defined in System.Random 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 CIntPtr | |
Random CUIntPtr | |
Random CIntMax | |
Random CUIntMax | |
Noise, random signals, and stochastic event sources
noise :: (RandomGen g, Random b) => g -> SF a b Source #
Noise (random signal) with default range for type in question; based on "randoms".
noiseR :: (RandomGen g, Random b) => (b, b) -> g -> SF a b Source #
Noise (random signal) with specified range; based on "randomRs".
occasionally :: RandomGen g => g -> Time -> b -> SF a (Event b) Source #
Stochastic event source with events occurring on average once every t_avg seconds. However, no more than one event results from any one sampling interval in the case of relatively sparse sampling, thus avoiding an "event backlog" should sampling become more frequent at some later point in time.