module Simulation.Aivika.Dynamics.Random
(memoRandomUniformDynamics,
memoRandomUniformIntDynamics,
memoRandomNormalDynamics,
memoRandomExponentialDynamics,
memoRandomErlangDynamics,
memoRandomPoissonDynamics,
memoRandomBinomialDynamics) where
import System.Random
import Control.Monad.Trans
import Simulation.Aivika.Generator
import Simulation.Aivika.Internal.Specs
import Simulation.Aivika.Internal.Parameter
import Simulation.Aivika.Internal.Simulation
import Simulation.Aivika.Internal.Dynamics
import Simulation.Aivika.Dynamics.Memo.Unboxed
memoRandomUniformDynamics :: Dynamics Double
-> Dynamics Double
-> Simulation (Dynamics Double)
memoRandomUniformDynamics min max =
memo0Dynamics $
Dynamics $ \p ->
do let g = runGenerator $ pointRun p
min' <- invokeDynamics p min
max' <- invokeDynamics p max
generatorUniform g min' max'
memoRandomUniformIntDynamics :: Dynamics Int
-> Dynamics Int
-> Simulation (Dynamics Int)
memoRandomUniformIntDynamics min max =
memo0Dynamics $
Dynamics $ \p ->
do let g = runGenerator $ pointRun p
min' <- invokeDynamics p min
max' <- invokeDynamics p max
generatorUniformInt g min' max'
memoRandomNormalDynamics :: Dynamics Double
-> Dynamics Double
-> Simulation (Dynamics Double)
memoRandomNormalDynamics mu nu =
memo0Dynamics $
Dynamics $ \p ->
do let g = runGenerator $ pointRun p
mu' <- invokeDynamics p mu
nu' <- invokeDynamics p nu
generatorNormal g mu' nu'
memoRandomExponentialDynamics :: Dynamics Double
-> Simulation (Dynamics Double)
memoRandomExponentialDynamics mu =
memo0Dynamics $
Dynamics $ \p ->
do let g = runGenerator $ pointRun p
mu' <- invokeDynamics p mu
generatorExponential g mu'
memoRandomErlangDynamics :: Dynamics Double
-> Dynamics Int
-> Simulation (Dynamics Double)
memoRandomErlangDynamics beta m =
memo0Dynamics $
Dynamics $ \p ->
do let g = runGenerator $ pointRun p
beta' <- invokeDynamics p beta
m' <- invokeDynamics p m
generatorErlang g beta' m'
memoRandomPoissonDynamics :: Dynamics Double
-> Simulation (Dynamics Int)
memoRandomPoissonDynamics mu =
memo0Dynamics $
Dynamics $ \p ->
do let g = runGenerator $ pointRun p
mu' <- invokeDynamics p mu
generatorPoisson g mu'
memoRandomBinomialDynamics :: Dynamics Double
-> Dynamics Int
-> Simulation (Dynamics Int)
memoRandomBinomialDynamics prob trials =
memo0Dynamics $
Dynamics $ \p ->
do let g = runGenerator $ pointRun p
prob' <- invokeDynamics p prob
trials' <- invokeDynamics p trials
generatorBinomial g prob' trials'