Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Functions that vary chaotically based on their input. Useful for introducing deterministic noise in pure code, e.g. for slightly moving points around, in the middle of pure code.
Synopsis
- class MwcChaosSource a where
- initializeMwc :: (PrimMonad m, MwcChaosSource a) => a -> m (Gen (PrimState m))
- class ChaosSource a where
- stdGen :: ChaosSource a => a -> StdGen
- normals :: ChaosSource seed => seed -> [Double]
- gaussian :: ChaosSource seed => Double -> Double -> seed -> [Double]
- normalVecs :: ChaosSource seed => seed -> [Vec2]
- gaussianVecs :: ChaosSource seed => Double -> Double -> seed -> [Vec2]
MWC-Random chaos
class MwcChaosSource a where Source #
Create a Word32
to initialize an MWC gen with. This is meant for simple and
convenient seed creation within pure code. Note that creating a generator to
produce a single value is probably much less efficient than using a worse
generator that is faster to seed.
Instances
initializeMwc :: (PrimMonad m, MwcChaosSource a) => a -> m (Gen (PrimState m)) Source #
Initialize an Gen
with anything MwcChaosSource
.
runST
$ do gen <-initializeMwc
(Vec2
3 3,regularPolygon
3)randomRM
(Vec2
0 0,Vec2
1 1) gen
STDGen chaos
class ChaosSource a where Source #
Types that can be turned into a random number generator easily, to yield pure chaotic output.
Add a value to the mix the StdGen
will be created from. Only used
for writing new instances of ChaosSource
.
To use instances of this class, use stdGen
.
Instances
stdGen :: ChaosSource a => a -> StdGen Source #
Create a StdGen
which can be used with System.Random’s functions,
based on a variety of inputs.
Utilities
normals :: ChaosSource seed => seed -> [Double] Source #
Infinite list of normally distributed values.
:: ChaosSource seed | |
=> Double | Mean |
-> Double | Standard deviation |
-> seed | |
-> [Double] |
Infinite list of Gaussian distributed values.
normalVecs :: ChaosSource seed => seed -> [Vec2] Source #
gaussianVecs :: ChaosSource seed => Double -> Double -> seed -> [Vec2] Source #