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