Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Starsim

PyPI version Downloads Tests

Starsim is fast, flexible disease modeling framework. It supports modeling multiple co-transmitting diseases, including infectious and non-infectious diseases plus other health states (such as pregnancy and birth), and captures their biological and behavioral interactions. It lets users compare intervention strategies, such as vaccines or treatments, across delivery methods like mass campaigns or targeted outreach. It also includes built-in tools for scenario analyses and calibrating models to real-world data.

Starsim builds on our previous suite of disease-specific models, including Covasim and HPVsim, as well as many other disease modeling frameworks (see below). It can model different levels of detail, including agent-based, metapopulation, and deterministic or stochastic compartmental modeling. It is designed to be simple and fast enough to enable rapid or exploratory analyses (from project start to calibrated model and scenario analyses in hours to days), while also being flexible enough to support complex, long-term research projects (such as intrahost immunity, data-driven spatial network transmission, and health economics optimization).

For more information, see the documentation or the code. For Starsim for R, see r.starsim.org. For Starsim's AI tools, see ai.starsim.org.

Starsim features

Starsim includes an extensive library of features aimed to support a broad diversity of disease modeling needs. The full set is listed in the documentation. Because the features are modular and written in Python, you can mix-and-match Starsim features with custom-written code, and you only use what you need. Highlights include:

  • Modeling modalities: Switch between compartmental, stochastic compartmental, metapopulation, and agent-based modeling using a flag (solver='abm') without needing to rewrite any code;
  • Performance: Numeric kernels are heavily optimized, including just-in-time compilation and GPU support (via JAX);
  • Diseases: A large library of already-implemented diseases including HIV, TB, malaria, COVID, flu, measles, HPV, syphilis, gonorrhea, chlamydia, rotavirus, typhoid, cholera, Ebola and many others; diseases support coinfection between different diseases, as well as multiple strains of a single disease;
  • Networks: Contact networks including age-stratified contact matrices, sexual (including male-female, male-male, and commercial), respiratory (household/workplace/school); also supports other forms of disease transmission including environmental and vector-borne;
  • Interventions: Flexible options for representing interventions, including screening, diagnostics, treatments, vaccination, and care cascades; health system considerations such as prioritization, capacity constraints, and clinic visits;
  • Costing: Support for intervention- and disease-related costs, health outcomes like disability-adjusted life years (DALYs), and budget optimization;
  • Time: Unit-aware time and date handling, including natural dates for data and plotting, module-specific timesteps, and timestep-aware conversion of rates and probabilities;
  • Data: Extensive built-in data, including population and age structures for every country, contact matrices (Prem et al., 2021), and geospatial boundaries;
  • Fitting: Automatic gradients for compartmental models, plus Bayesian fitting and calibrating algorithms including no-U-turn sampling (NUTS) and the tree-structured Parzen estimator (Optuna);
  • Scientific rigor: Automatic dimension checking to prevent common programming errors; common random numbers that allow exact comparison between even stochastic model runs;
  • Intercompatibility: Automated import and export from more than a dozen other disease modeling frameworks, and interoperable with other disease modeling tools like GeoPops and HubVerse;
  • AI support: Extensive set of skills and plugins that help implement Starsim models, including no-code chat interfaces for policymakers (EpiChat).

Starsim "stands on the shoulders of giants", and aims to build on the best aspects of other disease modeling frameworks. It is especially indebted to EpiModel, MEmilio, SimInf, summer2, camdl, epidemics, and epydemix (see the full list). If there's a feature you think Starsim should support, please get in touch.

Starsim models

Starsim is the basis of several other established disease modeling frameworks. These include:

  • Covasim, for modeling COVID-19;
  • HPVsim, for modeling human papillomavirus and cervical cancer;
  • STIsim, for modeling HIV, syphilis, gonorrhea, chlamydia, trichomoniasis, and bacterial vaginosis (including co-transmission);
  • TBsim, for modeling tuberculosis, including drug resistance;
  • FPsim, for modeling family planning and women's life courses.

A full list of diseases modeled using Starsim is available in the documentation.

Installation

If you're new to Python, check out our getting started guide. You can also use our installer, which will install Python along with all required dependencies.

Requirements

Python 3.12-3.14 or R.

We recommend, but do not require, installing Starsim in a virtual environment, such as uv or conda.

Python

Starsim is most easily installed via PyPI:

pip install "starsim[jax]"
starsim init

JAX is recommended, for gradients, fitting with them, and long runs. It is optional since it has no builds for Windows on Arm: there, use pip install starsim, and everything else works. Intel Macs are not supported.

starsim init compiles Starsim (once, which takes a few minutes and makes the first runs faster) and installs its skill for AI coding agents such as Claude Code and Codex (type /starsim to use it). To do just one of these, run starsim compile or starsim ai.

Or with uv:

uv init example
cd example
uv add "starsim[jax]"

Starsim can also be installed locally (including optional dependencies for testing and documentation). To do this, clone first this repository, then run:

pip install -e .[dev]

R

R-Starsim can be installed with:

# install.packages("devtools")
devtools::install_github("starsimhub/rstarsim")
library(starsim)
init_starsim()

See r.starsim.org for more information.

Usage and documentation

Full documentation, including tutorials and an API reference, is available at docs.starsim.org.

You can run a simple demo via:

import starsim as ss
ss.demo()

Here's how you'd write a minimal compartmental SIR model with an infection rate of 0.3 per step and a mean recovery duration of 10 steps:

import starsim as ss

S, I, R = ss.states(3)
sir = ss.Disease(
    infection = ss.Transition(S, I, rate=0.3*I),
    recovery = ss.Transition(I, R, dur=10)
)

sim = ss.Sim(sir).run()
sim.sir.plot()

If you prefer something that looks more like equations rather than code, there's an even more compact notation available:

import starsim as ss

S, I, R = ss.states(3) # Create model states
inf = S >> I @ 0.3*I   # Define infection at rate beta, mediated by I (*S/N implied)
rec = I >> R @ 0.1     # Define spontaneous recovery
ss.Sim(inf, rec).run().plot() # Create, run, and plot the simulation

The code above runs as a compartmental model by default, but you can also run it as an agent-based model (ABM) if you prefer. ABMs come with additional flexibility, such as defining explicit contact networks:

import starsim as ss

# Define the parameters
pars = dict(
    n_agents = 5_000,     # Number of agents to simulate
    networks = dict(      # Networks define how agents interact with each other
        type = 'random',  # Use the built-in 'random' network
        n_contacts = 10   # Each person has 10 contacts with other people  
    ),
    diseases = dict(      # Define the disease dynamics
        type = 'sir',     # Use the built-in SIR disease (including built-in parameters)
        init_prev = 0.01, # Proportion of the population initially infected
        beta = 0.05,      # Probability of transmission between contacts
    )
)

# Make the sim, run and plot
sim = ss.Sim(pars)
sim.run() # Runs as an agent-based model since uses an explicit network
sim.plot() # Plot all the sim results
sim.sir.plot() # Plot the standard SIR curves

Or from R:

library(starsim)
load_starsim()

# Define the parameters
pars <- list(
    n_agents = 5000,
    networks = list(type = 'random'),
    diseases = list(type = 'sir', beta = 0.1)
)

# Create, run, and plot the simulation
sim <- ss$Sim(pars)
sim$run()
sim$diseases$sir$plot()

More usage examples are available in the tutorials and user guide.

AI integration

Starsim-AI includes AI agents, skills, plugins, and MCP servers that ensure your favorite AI-enabled editor/tool is Starsim-aware. These include skills trained on different components of Starsim, as well as general software engineering and debugging skills. For details, see the Starsim-AI project.

Contributing

We welcome contributions of all kinds! Questions or comments can be directed to info@starsim.org , or on this project's GitHub page. Full information about Starsim is provided in the documentation.

AI disclaimer

We believe in being transparent about AI use. Each page comes with a little note estimating the human vs. AI contribution; hover to get more info. For this page:

Authorship: 🧠90%, 🤖10%

Metadata

Release files for starsim 4.0.0rc1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for starsim 4.0.0rc1
File Size Uploaded Provenance Actions
starsim-4.0.0rc1.tar.gz 3.4 MB With provenance Details for starsim-4.0.0rc1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for starsim 4.0.0rc1
File Actions
starsim-4.0.0rc1-cp312-abi3-win_arm64.whl CPython 3.12 abi3 Windows ARM64 Details for starsim-4.0.0rc1-cp312-abi3-win_arm64.whl
starsim-4.0.0rc1-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details for starsim-4.0.0rc1-cp312-abi3-win_amd64.whl
starsim-4.0.0rc1-cp312-abi3-manylinux_2_28_x86_64.whl CPython 3.12 abi3 Linux glibc 2.28+ x86-64 Details for starsim-4.0.0rc1-cp312-abi3-manylinux_2_28_x86_64.whl
starsim-4.0.0rc1-cp312-abi3-manylinux_2_28_aarch64.whl CPython 3.12 abi3 Linux glibc 2.28+ ARM64 Details for starsim-4.0.0rc1-cp312-abi3-manylinux_2_28_aarch64.whl
starsim-4.0.0rc1-cp312-abi3-macosx_11_0_arm64.whl CPython 3.12 abi3 macOS 11.0+ ARM64 Details for starsim-4.0.0rc1-cp312-abi3-macosx_11_0_arm64.whl

Total release size: 16.2 MB

Release files / starsim-4.0.0rc1.tar.gz

Download URL starsim-4.0.0rc1.tar.gz
Size 3.4 MB
Tags Source
SHA-256 checksum
How to use checksums
01d58f0414e26260d55bf6716ce3cbe9737a3a947f1e322a2bbd51367bdefcce
BLAKE2b-256 checksum
How to use checksums
bdae5b73a7d980f93d29e7634160ede93f59bf5fd5be4c997a0d3f89e990968f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / starsim-4.0.0rc1-cp312-abi3-win_arm64.whl

Download URL starsim-4.0.0rc1-cp312-abi3-win_arm64.whl
Size 2.5 MB
Tags CPython 3.12 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
19343d69d085577d9b78529f0868fa1056e7a6941e19d4195d1cfeca8497184a
BLAKE2b-256 checksum
How to use checksums
88bab6a83ce3380e98dc46e59a3436429dabaae303e68aec711ae3fa23fb67e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / starsim-4.0.0rc1-cp312-abi3-win_amd64.whl

Download URL starsim-4.0.0rc1-cp312-abi3-win_amd64.whl
Size 2.6 MB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
4db232df05b119a8bca15957dc8578d67a5226f0a00e21cf4815b492ba13da06
BLAKE2b-256 checksum
How to use checksums
5dd802d4d6b97d1612d8b47211145a5377a72e81c68a8ff03ba17fa352660e12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / starsim-4.0.0rc1-cp312-abi3-manylinux_2_28_x86_64.whl

Download URL starsim-4.0.0rc1-cp312-abi3-manylinux_2_28_x86_64.whl
Size 2.7 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
94631400bf716ddd92874b9f56f911ea2e4ed8972bbce04a1f3e5d89cdf59402
BLAKE2b-256 checksum
How to use checksums
d600173b69da3b7ddfdbf9eb5a1485c10f82b721f8b945e41c1e80826a42ba70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / starsim-4.0.0rc1-cp312-abi3-manylinux_2_28_aarch64.whl

Download URL starsim-4.0.0rc1-cp312-abi3-manylinux_2_28_aarch64.whl
Size 2.6 MB
Tags CPython 3.12 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
c687cec5a59b9555500af6f6cd4a1d2f1c88807c20abb5839e22249c57f40e7a
BLAKE2b-256 checksum
How to use checksums
11ed9819dc8abddde8dcc207c1a35ad6b2e45a48dd27af95fae7d09ca4816289
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / starsim-4.0.0rc1-cp312-abi3-macosx_11_0_arm64.whl

Download URL starsim-4.0.0rc1-cp312-abi3-macosx_11_0_arm64.whl
Size 2.5 MB
Tags CPython 3.12 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7b32c42c56d121d064d8cfda3532dc512d7b1e7b18d741dcbec7475c3f8f6cfa
BLAKE2b-256 checksum
How to use checksums
fb6f58a28ee27cb8d0f9e92c9b2f014dab6851996f16c655bd6bf70a6f82a2af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Security for starsim 4.0.0rc1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for starsim-4.0.0rc1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page