- type Event a = a -> Bool
- oneOf :: Eq a => [a] -> Event a
- just :: Eq a => a -> Event a
- newtype Probability = P ProbRep
- type ProbRep = Float
- precision :: Int
- showPfix :: ProbRep -> String
- roundRel :: RealFrac a => Int -> a -> a
- showP :: ProbRep -> String
- errorMargin :: ProbRep
- (>@>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c
- sequ :: Monad m => [a -> m a] -> a -> m a
- newtype Dist a = D {}
- isZero :: Dist a -> Bool
- onD :: ([(a, ProbRep)] -> [(a, ProbRep)]) -> Dist a -> Dist a
- sizeD :: Dist a -> Int
- checkD :: Dist a -> Dist a
- mkD :: [(a, ProbRep)] -> Dist a
- sumP :: [(a, ProbRep)] -> ProbRep
- sortP :: [(a, ProbRep)] -> [(a, ProbRep)]
- normBy :: Ord a => (a -> a -> Bool) -> Dist a -> Dist a
- accumBy :: Num b => (a -> a -> Bool) -> [(a, b)] -> [(a, b)]
- norm :: Ord a => Dist a -> Dist a
- norm' :: Ord a => [(a, ProbRep)] -> [(a, ProbRep)]
- joinWith :: (a -> b -> c) -> Dist a -> Dist b -> Dist c
- prod :: Dist a -> Dist b -> Dist (a, b)
- type Spread a = [a] -> Dist a
- certainly :: Trans a
- impossible :: Dist a
- choose :: ProbRep -> a -> a -> Dist a
- enum :: [ProbRep] -> Spread a
- enumPC :: [ProbRep] -> Spread a
- relative :: [Int] -> Spread a
- shape :: (Float -> Float) -> Spread a
- linear :: Float -> Spread a
- uniform :: Spread a
- negexp :: Spread a
- normal :: Spread a
- normalCurve :: Float -> Float -> Float -> Float
- extract :: Dist a -> [a]
- mapD :: (a -> b) -> Dist a -> Dist b
- unfoldD :: Dist (Dist a) -> Dist a
- cond :: Dist Bool -> Dist a -> Dist a -> Dist a
- truth :: Dist Bool -> Probability
- (|||) :: Dist a -> Event a -> Dist a
- data Select a
- above :: Ord a => ProbRep -> Dist a -> Dist (Select a)
- scale :: [(a, ProbRep)] -> Dist a
- filterD :: (a -> Bool) -> Dist a -> Dist a
- selectP :: Dist a -> ProbRep -> a
- scanP :: ProbRep -> [(a, ProbRep)] -> a
- (??) :: Event a -> Dist a -> Probability
- class ToFloat a where
- class FromFloat a where
- class Expected a where
- variance :: Expected a => Dist a -> Float
- stddev :: Expected a => Dist a -> Float
- type R a = IO a
- printR :: Show a => R a -> R ()
- pick :: Dist a -> R a
- type RDist a = R (Dist a)
- rAbove :: Ord a => ProbRep -> RDist a -> RDist (Select a)
- type Change a = a -> a
- type Trans a = a -> Dist a
- idT :: Trans a
- mapT :: Change a -> Trans a -> Trans a
- unfoldT :: Dist (Trans a) -> Trans a
- type SpreadC a = [Change a] -> Trans a
- certainlyT :: Change a -> Trans a
- maybeT :: ProbRep -> Change a -> Trans a
- liftC :: Spread a -> [Change a] -> Trans a
- uniformT :: [Change a] -> Trans a
- normalT :: [Change a] -> Trans a
- linearT :: Float -> [Change a] -> Trans a
- enumT :: [ProbRep] -> [Change a] -> Trans a
- type SpreadT a = [Trans a] -> Trans a
- liftT :: Spread (Trans a) -> [Trans a] -> Trans a
- uniformTT :: [Trans a] -> Trans a
- normalTT :: [Trans a] -> Trans a
- linearTT :: Float -> [Trans a] -> Trans a
- enumTT :: [ProbRep] -> [Trans a] -> Trans a
- type RChange a = a -> R a
- random :: Trans a -> RChange a
- type RTrans a = a -> RDist a
- type ApproxDist a = R [a]
- rDist :: Ord a => [R a] -> RDist a
- class Iterate c where
- class Sim c where
- type Trace a = [a]
- type Space a = Trace (Dist a)
- type Walk a = a -> Trace a
- type Expand a = a -> Space a
- (>>:) :: Trans a -> Expand a -> Expand a
- walk :: Int -> Change a -> Walk a
- (*..) :: Int -> Trans a -> Expand a
- type RTrace a = R (Trace a)
- type RSpace a = R (Space a)
- type RWalk a = a -> RTrace a
- type RExpand a = a -> RSpace a
- composelR :: RChange a -> RWalk a -> RWalk a
- rWalk :: Int -> RChange a -> RWalk a
- mergeTraces :: Ord a => [RTrace a] -> RSpace a
Auxiliary definitions
Events
Probabilities
Monad composition
Deterministic and probabilistic values
Distributions
probability disribution
Auxiliary functions for constructing and working with distributions
Normalization = grouping
Operations on distributions
joinWith :: (a -> b -> c) -> Dist a -> Dist b -> Dist cSource
product of independent distributions, identical to Monad.liftM2
Spread: functions to convert a list of values into a distribution
impossible :: Dist aSource
unfoldD :: Dist (Dist a) -> Dist aSource
unfold a distribution of distributions into one distribution
truth :: Dist Bool -> ProbabilitySource
filtering distributions
(??) :: Event a -> Dist a -> ProbabilitySource
Randomized values
R random value
RDist random distribution
Deterministic and probabilistic generators
Transitions
Spreading changes into transitions
type SpreadC a = [Change a] -> Trans aSource
functions to convert a list of changes into a transition
certainlyT :: Change a -> Trans aSource
Spreading transitions into transitions
type SpreadT a = [Trans a] -> Trans aSource
functions to convert a list of transitions into a transition
Randomized generators
Randomized changes
Randomized transitions
type ApproxDist a = R [a]Source
rDist :: Ord a => [R a] -> RDist aSource
rDist
converts a list of randomly generated values into
a distribution by taking equal weights for all values
Iteration and simulation
Naming convention:
-
*
takesn :: Int
and a generator and iterates the generator n times -
.
produces a single result -
..
produces a trace -
~
takesk :: Int
[andn :: Int
] and a generator and simulates the [n-fold repetition of the] generator k times
There are the following functions:
-
n *. t
iterates t and produces a distribution -
n *.. t
iterates t and produces a trace -
k ~. t
simulates t and produces a distribution -
(k,n) ~*. t
simulates the n-fold repetition of t and produces a distribution -
(k,n) ~.. t
simulates the n-fold repetition of t and produces a trace
Iteration captures three iteration strategies: iter builds an n-fold composition of a (randomized) transition while and until implement conditional repetitions
The class Iterate allows the overloading of iteration for different kinds of generators, namely transitions and random changes:
Trans a = a -> Dist a ==> c = Dist
RChange a = a -> R a ==> c = R = IO
Simulation means to repeat a random chage many times and to accumulate all results into a distribution. Therefore, simulation can be regarded as an approximation of distributions through randomization.
The Sim class allows the overloading of simulation for different kinds of generators, namely transitions and random changes:
Trans a = a -> Dist a ==> c = Dist
RChange a = a -> R a ==> c = R = IO
Tracing
(>>:) :: Trans a -> Expand a -> Expand aSource
(>>:)
composes the result of a transition with a space
(transition is composed on the left)
(a -> m a) -> (a -> [m a]) -> (a -> [m a])
(*..) :: Int -> Trans a -> Expand aSource
(*..)
is identical to (*.)
,
but returns the list of all intermediate distributions
rWalk :: Int -> RChange a -> RWalk aSource
rWalk
computes a list of values by randomly selecting
one value from a distribution in each step.
mergeTraces :: Ord a => [RTrace a] -> RSpace aSource
mergeTraces
converts a list of RTrace
s
into a list of randomized distributions, i.e., an RSpace
,
by creating a randomized distribution for each list position across all traces