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 a fast, flexible disease modeling framework, from compartments to agents. 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 covered 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 (solvers);
  • Performance: Numeric kernels are heavily optimized, with Numba and Rust kernels that give the same numbers, plus GPU support (via JAX) (performance);
  • Diseases: A large library of already-implemented diseases including HIV, TB, malaria, COVID, flu, measles, syphilis, gonorrhea, typhoid, cholera, Ebola and many others (plus HPV, chlamydia, rotavirus, and others in the models below); diseases support coinfection between different diseases, as well as multiple strains of a single disease (library diseases, diseases);
  • 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 (networks, library networks);
  • 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 (interventions, products);
  • Costing: Support for intervention- and disease-related costs, health outcomes like disability-adjusted life years (DALYs), and budget optimization (costs, 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 (time);
  • Data and places: Extensive built-in data, including population and age structures for 187 countries and territories, contact matrices (Prem et al., 2021), and geospatial boundaries, with maps and animations of results by place (population data, geography);
  • 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) (fitting, methods);
  • Scientific rigor: Automatic checking of units to prevent common programming errors; common random numbers that allow exact comparison between even stochastic model runs (time, random numbers);
  • Intercompatibility: Automated import from more than a dozen other disease modeling frameworks, and export to SBML and odin (import and export); interoperable with other disease modeling tools like GeoPops and HubVerse;
  • AI support: Extensive set of skills and plugins that help implement Starsim models (AI integration), 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 Numba's kernels if the Rust ones are not available (which takes a few minutes, once, and makes the first runs faster; the wheels on PyPI include the Rust kernels, so there is usually nothing to compile) and, if an AI coding agent such as Claude Code or Codex is installed, links Starsim's skills into your project (type /starsim to use them). To do just one of these, run starsim init compile or starsim init ai.

Or with uv:

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

To work on Starsim itself, clone this repository, then run:

pip install -e .
starsim init dev

This installs the optional dependencies for testing and documentation, and JAX; installs Rust if it is missing; and builds Starsim's kernels. See the developer guide for details.

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 comes with skills for AI coding agents (Claude Code, Codex, and others), which always match the version installed: how to write, check, and run a model, and how to import a model from another framework or upgrade one from Starsim 3. starsim init ai (part of starsim init) links them into your project, and starsim ai install --global sets them up for all your projects instead; tools that read skills from installed packages, such as uvx library-skills, find them too. starsim ai "how would I model a leaky vaccine?" asks your agent a question about Starsim (-i for an interactive session), and starsim help RandomNet looks a name or term up in the docs, without an agent. For anything else, llms.txt is a map of the docs and the API for agents.

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.0rc3

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.0rc3
File Size Uploaded Provenance Actions
starsim-4.0.0rc3.tar.gz 3.8 MB With provenance Details for starsim-4.0.0rc3.tar.gz

Built distributions (wheels)

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

Total release size: 17.9 MB

Release files / starsim-4.0.0rc3.tar.gz

Download URL starsim-4.0.0rc3.tar.gz
Size 3.8 MB
Tags Source
SHA-256 checksum
How to use checksums
9328154548177f8aea6d497b1bac496691f43e7a4a72c6e28d867adaf0322c14
BLAKE2b-256 checksum
How to use checksums
5eb5b3b35f9a09a990989112211c69aa6e164f23c0acd33e12650642c6705553
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 8, 2026.

Transparency log

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

Download URL starsim-4.0.0rc3-cp312-abi3-win_arm64.whl
Size 2.7 MB
Tags CPython 3.12 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
aa6b23c8b0b629e9f1caa2140ee74576a90923d5a7decf5e6a083956c6a12f15
BLAKE2b-256 checksum
How to use checksums
973ebe5617465c745b8230b1595473d034a7a4062d68a91b922979166b40266e
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 8, 2026.

Transparency log

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

Download URL starsim-4.0.0rc3-cp312-abi3-win_amd64.whl
Size 2.8 MB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
ac9f774e63628e1bdc747332c8422cd83f4f0d084c8b79e12ea0841f3f833136
BLAKE2b-256 checksum
How to use checksums
cea7f53d2812ebdc745887988ae42c42725dca788b8d802f568f18c2a1a1fc5f
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 8, 2026.

Transparency log

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

Download URL starsim-4.0.0rc3-cp312-abi3-manylinux_2_28_x86_64.whl
Size 2.9 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
1047e0152773cc6b6c1c4267ccd8ad7b7d84a2cb00d333e798076f9f604c01f4
BLAKE2b-256 checksum
How to use checksums
5eb9f69b2a527e8393a06db31dad63d558e87ee122b3b9a322245184ff7ebdff
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 8, 2026.

Transparency log

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

Download URL starsim-4.0.0rc3-cp312-abi3-manylinux_2_28_aarch64.whl
Size 2.8 MB
Tags CPython 3.12 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
4059206b2f4495a76cd18b2533092adf8f0d02162f34d4c1f74a8ff7714a3fa1
BLAKE2b-256 checksum
How to use checksums
65769682f3c0e366371a060efc40ff651b182e1091c46b4182a23e473e07bc15
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 8, 2026.

Transparency log

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

Download URL starsim-4.0.0rc3-cp312-abi3-macosx_11_0_arm64.whl
Size 2.8 MB
Tags CPython 3.12 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2a1739acd790b0f9cb24b2b26b4e3be26d546d30820d0d7390a86f993661f9cd
BLAKE2b-256 checksum
How to use checksums
28225404daf3d1d3cfc9296934652f0f14ffa871057a276ac43b1a7a5ab80323
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 8, 2026.

Transparency log

Security for starsim 4.0.0rc3

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.0rc3.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 8, 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