-- | SimulationmoduleNumeric.Probability.SimulationwhereimportqualifiedNumeric.Probability.Distribution asDistimportqualifiedNumeric.Probability.Random asRndimportqualifiedNumeric.Probability.Trace asTraceimportSystem.Random(Random,)importqualifiedNumeric.Probability.Monad asMonadExt{-
Naming convention:
 * @*@ takes @n :: Int@ and a generator and iterates the generator n times
 * @.@ produces a single result
 * @..@ produces a trace
 * @~@ takes @k :: Int@ [and @n :: 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 Rnd.change changes:
 * @Trans a = a -> Dist a ==> c = Dist@
 * @RChange a = a -> Rnd.T a ==> c = Rnd.T = IO@
-}{- |
Simulation means to repeat a Rnd.change change 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 Rnd.change changes:
 * @Trans a = a -> Dist a ==> c = Dist@
 * @RChange a = a -> Rnd.T a ==> c = Rnd.T = IO@
-}classC c where-- | returns the final randomized transition(~. )::(Fractionalprob ,Ordprob ,Randomprob ,Orda )=>Int->(a ->c a )->Rnd.Transition prob a -- | returns the whole trace for a k-fold simulation(~.. )::(Fractionalprob ,Ordprob ,Randomprob ,Orda )=>(Int,Int)->(a ->c a )->Trace.RExpand prob a -- | returns the whole trace for a single simulation(~*. )::(Fractionalprob ,Ordprob ,Randomprob ,Orda )=>(Int,Int)->(a ->c a )->Rnd.Transition prob a infix6~. ,~.. infix8~*. -- simulation for transitions--instance(Numprob ,Ordprob ,Randomprob )=>C (Dist.T prob )where(~. )x =(~. )x .Rnd.change (~.. )x =(~.. )x .Rnd.change (~*. )x =(~*. )x .Rnd.change -- simulation for Rnd.change changes--instanceC Rnd.T where(~. )n t =Rnd.dist .replicaten .t (~.. )(k ,n )t =Trace.merge .replicatek .MonadExt.walk n t (~*. )(k ,n )t =k ~. MonadExt.iterate n t 

AltStyle によって変換されたページ (->オリジナル) /