Skip to content

Examples

A collection of examples demonstrating epiworld's capabilities. Examples include an interactive playground powered by Compiler Explorer.

Example Description
Hello World Demonstrates the basic usage of epiworld by creating a custom model with custom states, a virus, and a tool on a small-world network.
SEIR Model A basic SEIR (Susceptible-Exposed-Infected-Recovered) epidemic model using the built-in ModelSEIR class.
SIR Model A classic SIR (Susceptible-Infected-Recovered) epidemic model using the built-in ModelSIR class on a small-world network.
SIS Model A Susceptible-Infected-Susceptible (SIS) endemic model where recovered agents can be re-infected.
SIR: Multiple Runs Runs the SIR model multiple times using run_multiple and collects summary statistics across replicates.
SIR: Multiple Runs with Plotting Extends the multiple-run SIR example with post-processing resources for R-based visualization of replicate results.
Simple SIR A minimal SIR simulation built step-by-step from scratch, illustrating state definitions, virus setup, and network generation.
User Data Shows how to attach arbitrary user-defined data to agents and retrieve it during and after the simulation.
SIR with OpenMP (requires OpenMP) Runs multiple independent SIR simulations in parallel using OpenMP, demonstrating thread-level parallelism for large-scale studies.
SIR with OpenMP (Callbacks) (requires OpenMP) Extends the OpenMP parallel SIR example with custom per-replicate callbacks for collecting results across threads.
Surveillance Model Uses the built-in ModelSURV surveillance model to simulate disease spread with active case detection and vaccination.
Likelihood-Free MCMC Demonstrates likelihood-free Markov Chain Monte Carlo (LFMCMC) for Bayesian parameter estimation of an SIR model.
Entities Illustrates how to create structured populations using entities (e.g., groups, households) with contact matrices.
Generation Interval Calculates and displays the generation interval and reproductive number for an SIR-like model.
Community and Hospital Models disease transmission in two linked populations - a community and a hospital - with admission and discharge events.
SEIRD Transitions Builds a SEIRD model using the new_state_update_transition factory function instead of hand-written lambda update functions.
Stochastic Block Model Generates contact networks using the stochastic block model (SBM) and runs an SIR simulation on it.
SBM Scalability Benchmark Benchmarks rgraph_sbm, rgraph_bernoulli, and rgraph_smallworld across varying population sizes to compare network generation performance.
SEIR Quarantine Benchmark Benchmarks the ModelSEIRNetworkQuarantine model with contact tracing and isolation for varying population sizes.
Poisson vs. Binomial Sampling Compares epiworld's rbinom and rpoiss random number generators to verify the Poisson approximation to the Binomial distribution.