epi-sim-0.7.0: A library for simulating epidemics as birth-death processes.
Safe HaskellNone
LanguageHaskell2010

Epidemic.Utility

Synopsis

Documentation

inhomExponential Source #

Arguments

:: PrimMonad m 
=> Timed Double

Step function

-> AbsoluteTime

Start time

-> Gen (PrimState m)

Generator

-> m (Maybe AbsoluteTime) 

Generate exponentially distributed random variates with inhomogeneous rate starting from a particular point in time.

Assuming the stepFunc is the intensity of arrivals and t0 is the start time this returns t1 the time of the next arrival.

randomPerson :: People -> GenIO -> IO (Person, People) Source #

A random person and the remaining group of people after they have been sampled with removal.

maybeToRight :: a -> Maybe b -> Either a b Source #

Helper function for converting between the Maybe monad and the Either monad.

newPerson :: Identifier -> (Person, Identifier) Source #

A new person constructed from the given identifier and a new identifier.

isReconTreeLeaf :: EpidemicEvent -> Bool Source #

Predicate for whether an epidemic event will appear as a leaf in the reconstructed tree. For scheduled sequenced samples this will only return true if there was at least one lineage observed.

simulationWithSystem :: (ModelParameters a b, Population b) => SimulationConfiguration a b c -> (a -> AbsoluteTime -> Maybe (TerminationHandler b c) -> SimulationState b c -> GenIO -> IO (SimulationState b c)) -> IO (Either (Maybe c) [EpidemicEvent]) Source #

Run a simulation described by a configuration object but using a random seed generated by the system rather than a seed

simulationWithFixedSeed :: (ModelParameters a b, Population b) => SimulationConfiguration a b c -> (a -> AbsoluteTime -> Maybe (TerminationHandler b c) -> SimulationState b c -> GenIO -> IO (SimulationState b c)) -> IO (Either (Maybe c) [EpidemicEvent]) Source #

Run a simulation using a fixed PRNG random seed.

simulationWithGenIO :: (ModelParameters a b, Population b) => SimulationConfiguration a b c -> (a -> AbsoluteTime -> Maybe (TerminationHandler b c) -> SimulationState b c -> GenIO -> IO (SimulationState b c)) -> GenIO -> IO (Either (Maybe c) [EpidemicEvent]) Source #

Run a simulation described by a configuration object and the model's allEvents style function (see the example in Epidemic.Model.InhomogeneousBDSCOD) using the provided PRNG.