module Simulation.Aivika.Trans.Dynamics.Random
(memoRandomUniformDynamics,
memoRandomUniformIntDynamics,
memoRandomNormalDynamics,
memoRandomExponentialDynamics,
memoRandomErlangDynamics,
memoRandomPoissonDynamics,
memoRandomBinomialDynamics) where
import System.Random
import Control.Monad.Trans
import Simulation.Aivika.Trans.Generator
import Simulation.Aivika.Trans.Comp
import Simulation.Aivika.Trans.Internal.Specs
import Simulation.Aivika.Trans.Internal.Parameter
import Simulation.Aivika.Trans.Internal.Simulation
import Simulation.Aivika.Trans.Internal.Dynamics
import Simulation.Aivika.Trans.Dynamics.Memo.Unboxed
memoRandomUniformDynamics :: MonadComp m
=> Dynamics m Double
-> Dynamics m Double
-> Simulation m (Dynamics m Double)
memoRandomUniformDynamics min max =
memo0Dynamics $
Dynamics $ \p ->
do let g = runGenerator $ pointRun p
min' <- invokeDynamics p min
max' <- invokeDynamics p max
generateUniform g min' max'
memoRandomUniformIntDynamics :: MonadComp m
=> Dynamics m Int
-> Dynamics m Int
-> Simulation m (Dynamics m Int)
memoRandomUniformIntDynamics min max =
memo0Dynamics $
Dynamics $ \p ->
do let g = runGenerator $ pointRun p
min' <- invokeDynamics p min
max' <- invokeDynamics p max
generateUniformInt g min' max'
memoRandomNormalDynamics :: MonadComp m
=> Dynamics m Double
-> Dynamics m Double
-> Simulation m (Dynamics m Double)
memoRandomNormalDynamics mu nu =
memo0Dynamics $
Dynamics $ \p ->
do let g = runGenerator $ pointRun p
mu' <- invokeDynamics p mu
nu' <- invokeDynamics p nu
generateNormal g mu' nu'
memoRandomExponentialDynamics :: MonadComp m
=> Dynamics m Double
-> Simulation m (Dynamics m Double)
memoRandomExponentialDynamics mu =
memo0Dynamics $
Dynamics $ \p ->
do let g = runGenerator $ pointRun p
mu' <- invokeDynamics p mu
generateExponential g mu'
memoRandomErlangDynamics :: MonadComp m
=> Dynamics m Double
-> Dynamics m Int
-> Simulation m (Dynamics m Double)
memoRandomErlangDynamics beta m =
memo0Dynamics $
Dynamics $ \p ->
do let g = runGenerator $ pointRun p
beta' <- invokeDynamics p beta
m' <- invokeDynamics p m
generateErlang g beta' m'
memoRandomPoissonDynamics :: MonadComp m
=> Dynamics m Double
-> Simulation m (Dynamics m Int)
memoRandomPoissonDynamics mu =
memo0Dynamics $
Dynamics $ \p ->
do let g = runGenerator $ pointRun p
mu' <- invokeDynamics p mu
generatePoisson g mu'
memoRandomBinomialDynamics :: MonadComp m
=> Dynamics m Double
-> Dynamics m Int
-> Simulation m (Dynamics m Int)
memoRandomBinomialDynamics prob trials =
memo0Dynamics $
Dynamics $ \p ->
do let g = runGenerator $ pointRun p
prob' <- invokeDynamics p prob
trials' <- invokeDynamics p trials
generateBinomial g prob' trials'