module Simulation.Aivika.Dynamics.Random
(memoRandomUniformDynamics,
memoRandomUniformIntDynamics,
memoRandomTriangularDynamics,
memoRandomNormalDynamics,
memoRandomLogNormalDynamics,
memoRandomExponentialDynamics,
memoRandomErlangDynamics,
memoRandomPoissonDynamics,
memoRandomBinomialDynamics,
memoRandomGammaDynamics,
memoRandomBetaDynamics,
memoRandomWeibullDynamics,
memoRandomDiscreteDynamics) where
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
import Simulation.Aivika.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
generateUniform 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
generateUniformInt g min' max'
memoRandomTriangularDynamics :: Dynamics Double
-> Dynamics Double
-> Dynamics Double
-> Simulation (Dynamics Double)
memoRandomTriangularDynamics min median max =
memo0Dynamics $
Dynamics $ \p ->
do let g = runGenerator $ pointRun p
min' <- invokeDynamics p min
median' <- invokeDynamics p median
max' <- invokeDynamics p max
generateTriangular g min' median' 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
generateNormal g mu' nu'
memoRandomLogNormalDynamics :: Dynamics Double
-> Dynamics Double
-> Simulation (Dynamics Double)
memoRandomLogNormalDynamics mu nu =
memo0Dynamics $
Dynamics $ \p ->
do let g = runGenerator $ pointRun p
mu' <- invokeDynamics p mu
nu' <- invokeDynamics p nu
generateLogNormal g mu' nu'
memoRandomExponentialDynamics :: Dynamics Double
-> Simulation (Dynamics Double)
memoRandomExponentialDynamics mu =
memo0Dynamics $
Dynamics $ \p ->
do let g = runGenerator $ pointRun p
mu' <- invokeDynamics p mu
generateExponential 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
generateErlang g beta' m'
memoRandomPoissonDynamics :: Dynamics Double
-> Simulation (Dynamics Int)
memoRandomPoissonDynamics mu =
memo0Dynamics $
Dynamics $ \p ->
do let g = runGenerator $ pointRun p
mu' <- invokeDynamics p mu
generatePoisson 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
generateBinomial g prob' trials'
memoRandomGammaDynamics :: Dynamics Double
-> Dynamics Double
-> Simulation (Dynamics Double)
memoRandomGammaDynamics kappa theta =
memo0Dynamics $
Dynamics $ \p ->
do let g = runGenerator $ pointRun p
kappa' <- invokeDynamics p kappa
theta' <- invokeDynamics p theta
generateGamma g kappa' theta'
memoRandomBetaDynamics :: Dynamics Double
-> Dynamics Double
-> Simulation (Dynamics Double)
memoRandomBetaDynamics alpha beta =
memo0Dynamics $
Dynamics $ \p ->
do let g = runGenerator $ pointRun p
alpha' <- invokeDynamics p alpha
beta' <- invokeDynamics p beta
generateBeta g alpha' beta'
memoRandomWeibullDynamics :: Dynamics Double
-> Dynamics Double
-> Simulation (Dynamics Double)
memoRandomWeibullDynamics alpha beta =
memo0Dynamics $
Dynamics $ \p ->
do let g = runGenerator $ pointRun p
alpha' <- invokeDynamics p alpha
beta' <- invokeDynamics p beta
generateWeibull g alpha' beta'
memoRandomDiscreteDynamics :: Unboxed a => Dynamics (DiscretePDF a) -> Simulation (Dynamics a)
memoRandomDiscreteDynamics dpdf =
memo0Dynamics $
Dynamics $ \p ->
do let g = runGenerator $ pointRun p
dpdf' <- invokeDynamics p dpdf
generateDiscrete g dpdf'