forsyde-atom-0.3.0.0: Shallow-embedded DSL for modeling cyber-physical systems
Copyright(c) George Ungureanu 2020
LicenseBSD-style (see the file LICENSE)
Maintainerugeorge@kth.se
Stabilityexperimental
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

ForSyDe.Atom.Prob.Uniform

Contents

Description

This module defines recipes for uniformly distributed random variables. Wraps utilities imported from System.Random.

Synopsis

Recipes

uniform :: Random a => Dist a Source #

Recipe for uniformly distributed over all possible values of that type.

>>> gen <- getStdGen
>>> let x = uniform :: Dist Float
>>> let hx = histogram (-0.5) 1.5 0.1 $ samplesn gen 10000 x
>>> dumpDat $ prepare defaultCfg hx
Dumped hist1 in ./fig
["./fig/hist1.dat"]

uniformR Source #

Arguments

:: Random a 
=> a

lower bound

-> a

upper bound

-> Dist a 

Recipe for uniformly distributed over a provided range.

>>> gen <- getStdGen
>>> let x = uniformR 0 20 :: Dist Int
>>> let hx = histogram (-1) 21 1 $ samplesn gen 10000 x
>>> dumpDat $ prepare defaultCfg hx
Dumped hist1 in ./fig
["./fig/hist1.dat"]

uniformD Source #

Arguments

:: (Random a, Num a) 
=> a

deviation

-> a

mean

-> Dist a 

Recipe for uniformly distributed over a range determined by standard deviation.

>>> gen <- getStdGen
>>> let x = uniformD 5 0.5 :: Dist Float
>>> let hx = histogram 4 6 0.1 $ samplesn gen 10000 x
>>> dumpDat $ prepare defaultCfg hx
Dumped hist1 in ./fig
["./fig/hist1.dat"]

Layer

The ForSyDe.Atom.Prob module is re-exported for convenience, so it does not need to be imported explicitly.