module Simulation.Aivika.Trans.Dynamics.Random
(memoRandomUniformDynamics,
memoRandomUniformIntDynamics,
memoRandomTriangularDynamics,
memoRandomNormalDynamics,
memoRandomLogNormalDynamics,
memoRandomExponentialDynamics,
memoRandomErlangDynamics,
memoRandomPoissonDynamics,
memoRandomBinomialDynamics,
memoRandomGammaDynamics,
memoRandomBetaDynamics,
memoRandomWeibullDynamics,
memoRandomDiscreteDynamics) where
import Simulation.Aivika.Trans.Generator
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
import Simulation.Aivika.Trans.SD
memoRandomUniformDynamics :: MonadSD m
=> Dynamics m Double
-> Dynamics m Double
-> Simulation m (Dynamics m Double)
{-# INLINABLE memoRandomUniformDynamics #-}
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 :: MonadSD m
=> Dynamics m Int
-> Dynamics m Int
-> Simulation m (Dynamics m Int)
{-# INLINABLE memoRandomUniformIntDynamics #-}
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 :: MonadSD m
=> Dynamics m Double
-> Dynamics m Double
-> Dynamics m Double
-> Simulation m (Dynamics m Double)
{-# INLINABLE memoRandomTriangularDynamics #-}
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 :: MonadSD m
=> Dynamics m Double
-> Dynamics m Double
-> Simulation m (Dynamics m Double)
{-# INLINABLE memoRandomNormalDynamics #-}
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 :: MonadSD m
=> Dynamics m Double
-> Dynamics m Double
-> Simulation m (Dynamics m Double)
{-# INLINABLE memoRandomLogNormalDynamics #-}
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 :: MonadSD m
=> Dynamics m Double
-> Simulation m (Dynamics m Double)
{-# INLINABLE memoRandomExponentialDynamics #-}
memoRandomExponentialDynamics mu =
memo0Dynamics $
Dynamics $ \p ->
do let g = runGenerator $ pointRun p
mu' <- invokeDynamics p mu
generateExponential g mu'
memoRandomErlangDynamics :: MonadSD m
=> Dynamics m Double
-> Dynamics m Int
-> Simulation m (Dynamics m Double)
{-# INLINABLE memoRandomErlangDynamics #-}
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 :: MonadSD m
=> Dynamics m Double
-> Simulation m (Dynamics m Int)
{-# INLINABLE memoRandomPoissonDynamics #-}
memoRandomPoissonDynamics mu =
memo0Dynamics $
Dynamics $ \p ->
do let g = runGenerator $ pointRun p
mu' <- invokeDynamics p mu
generatePoisson g mu'
memoRandomBinomialDynamics :: MonadSD m
=> Dynamics m Double
-> Dynamics m Int
-> Simulation m (Dynamics m Int)
{-# INLINABLE memoRandomBinomialDynamics #-}
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 :: MonadSD m
=> Dynamics m Double
-> Dynamics m Double
-> Simulation m (Dynamics m Double)
{-# INLINABLE memoRandomGammaDynamics #-}
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 :: MonadSD m
=> Dynamics m Double
-> Dynamics m Double
-> Simulation m (Dynamics m Double)
{-# INLINABLE memoRandomBetaDynamics #-}
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 :: MonadSD m
=> Dynamics m Double
-> Dynamics m Double
-> Simulation m (Dynamics m Double)
{-# INLINABLE memoRandomWeibullDynamics #-}
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 :: (MonadSD m, MonadMemo m a) => Dynamics m (DiscretePDF a) -> Simulation m (Dynamics m a)
{-# INLINABLE memoRandomDiscreteDynamics #-}
memoRandomDiscreteDynamics dpdf =
memo0Dynamics $
Dynamics $ \p ->
do let g = runGenerator $ pointRun p
dpdf' <- invokeDynamics p dpdf
generateDiscrete g dpdf'