module Simulation.Aivika.Trans.Parameter.Random
(randomUniform,
randomUniformInt,
randomTriangular,
randomNormal,
randomLogNormal,
randomExponential,
randomErlang,
randomPoisson,
randomBinomial,
randomGamma,
randomBeta,
randomWeibull,
randomDiscrete,
randomTrue,
randomFalse) where
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.Dynamics
import Simulation.Aivika.Trans.Dynamics.Memo.Unboxed
randomUniform :: MonadComp m
=> Double
-> Double
-> Parameter m Double
{-# INLINE randomUniform #-}
randomUniform min max =
Parameter $ \r ->
let g = runGenerator r
in generateUniform g min max
randomUniformInt :: MonadComp m
=> Int
-> Int
-> Parameter m Int
{-# INLINE randomUniformInt #-}
randomUniformInt min max =
Parameter $ \r ->
let g = runGenerator r
in generateUniformInt g min max
randomTriangular :: MonadComp m
=> Double
-> Double
-> Double
-> Parameter m Double
{-# INLINE randomTriangular #-}
randomTriangular min median max =
Parameter $ \r ->
let g = runGenerator r
in generateTriangular g min median max
randomNormal :: MonadComp m
=> Double
-> Double
-> Parameter m Double
{-# INLINE randomNormal #-}
randomNormal mu nu =
Parameter $ \r ->
let g = runGenerator r
in generateNormal g mu nu
randomLogNormal :: MonadComp m
=> Double
-> Double
-> Parameter m Double
{-# INLINE randomLogNormal #-}
randomLogNormal mu nu =
Parameter $ \r ->
let g = runGenerator r
in generateLogNormal g mu nu
randomExponential :: MonadComp m
=> Double
-> Parameter m Double
{-# INLINE randomExponential #-}
randomExponential mu =
Parameter $ \r ->
let g = runGenerator r
in generateExponential g mu
randomErlang :: MonadComp m
=> Double
-> Int
-> Parameter m Double
{-# INLINE randomErlang #-}
randomErlang beta m =
Parameter $ \r ->
let g = runGenerator r
in generateErlang g beta m
randomPoisson :: MonadComp m
=> Double
-> Parameter m Int
{-# INLINE randomPoisson #-}
randomPoisson mu =
Parameter $ \r ->
let g = runGenerator r
in generatePoisson g mu
randomBinomial :: MonadComp m
=> Double
-> Int
-> Parameter m Int
{-# INLINE randomBinomial #-}
randomBinomial prob trials =
Parameter $ \r ->
let g = runGenerator r
in generateBinomial g prob trials
randomGamma :: MonadComp m
=> Double
-> Double
-> Parameter m Double
{-# INLINE randomGamma #-}
randomGamma kappa theta =
Parameter $ \r ->
let g = runGenerator r
in generateGamma g kappa theta
randomBeta :: MonadComp m
=> Double
-> Double
-> Parameter m Double
{-# INLINE randomBeta #-}
randomBeta alpha beta =
Parameter $ \r ->
let g = runGenerator r
in generateBeta g alpha beta
randomWeibull :: MonadComp m
=> Double
-> Double
-> Parameter m Double
{-# INLINE randomWeibull #-}
randomWeibull alpha beta =
Parameter $ \r ->
let g = runGenerator r
in generateWeibull g alpha beta
randomDiscrete :: MonadComp m => DiscretePDF a -> Parameter m a
{-# INLINE randomDiscrete #-}
randomDiscrete dpdf =
Parameter $ \r ->
let g = runGenerator r
in generateDiscrete g dpdf
randomTrue :: MonadComp m
=> Double
-> Parameter m Bool
{-# INLINE randomTrue #-}
randomTrue p =
do x <- randomUniform 0 1
return (x <= p)
randomFalse :: MonadComp m
=> Double
-> Parameter m Bool
{-# INLINE randomFalse #-}
randomFalse p =
do x <- randomUniform 0 1
return (x > p)