Starsim ships with a collection of example models — illustrative implementations of diseases, networks, and analyses that aren’t part of the core library but show how Starsim can be used and extended. They come in two forms:
Library examples, importable via import starsim.library as ssl (e.g. ssl.diseases.HIV). These are maintained alongside Starsim and can be dropped straight into a simulation.
Standalone examples, kept as scripts in the docs/examples folder of the repository. These are meant to be read and adapted rather than imported.
Here’s a quick example running one of the library disease models:
import starsim as ssimport starsim.library as sslss.options(jupyter=True)# Run the measles model on a random networksim = ss.Sim(diseases=ssl.diseases.Measles(), networks='random', n_agents=5000, verbose=0)sim.run()sim.plot('measles')
These live as scripts in the repository rather than in the importable library:
Embedding network (embedding.py) — pairs agents based on a continuous similarity embedding.
Cross-language translations (translations/) — the same simple SIS model implemented in pure Python, Numba, JAX, Julia, and Rust, alongside the idiomatic Starsim version. Useful for understanding performance trade-offs and how Starsim relates to lower-level implementations.
LASER interoperability (laser/) — shows how Starsim models relate to LASER, including minimal and full Starsim equivalents of a LASER example and profiling scripts.