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

Note: Starsim v4 is now available. It's quite different from v3, with a new and simpler syntax for creating diseases, and support for compartmental and geospatial models. Models written for v3 will need to be migrated; see the changelog for details, or contact us for help. To continue using Starsim v3, use pip install starsim<4; the v3 docs are also still available. But really, please upgrade to v4! You'll be glad you did!

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 code is heavily optimized, with Numba and Rust backends that give the same numbers, plus GPU support (via JAX) (performance);
  • Diseases: A large library of already-implemented diseases including COVID, flu, measles, malaria, syphilis, gonorrhea, cholera, Ebola and many others (plus HIV, TB, COVID, HPV, chlamydia, typhoid, 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.
  • Typhoidsim, for modeling typhoid, including environmental transmission.

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. On Linux and macOS, run:

curl -LsSf https://docs.starsim.org/install.sh | sh

On Windows, download install.bat and double-click it.

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 if you'll be calibrating compartmental models -- otherwise you can skip it, i.e. pip install starsim.

starsim init compiles Starsim's numeric code if needed (usually it's not). It also asks if you want to install Starsim's AI skills (so you can type /starsim in your agent to use them). To do either the compile or the AI install, run starsim init compile or starsim init ai.

You can also of course install 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 Rust and Numba backends. 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.

Documentation

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

Usage

You can run a simple demo via:

import starsim as ss
ss.demo()

Here's a minimal SIR model, with an infection rate of β = 0.3 per day and an infectious period of 10 days, written much as you'd write it on paper:

import starsim as ss

S, I, R = ss.states('S I R') # Create the SIR states
infection = S >> I @ 0.3*I # From S to I, at a rate of β times the fraction infectious
recovery  = I >> R @ ss.days(10) # From I to R, after 10 days on average
sir = ss.Disease(infection, recovery) # Create the disease from the transitions

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

Results of the SIR model

The same model, written out in full:

import starsim as ss

S = ss.State(label='Susceptible')
I = ss.State(label='Infectious')
R = ss.State(name='Recovered')
beta = ss.perday(0.3)
dur_inf = ss.expon(mean=ss.days(10))
sir = ss.Disease(
    name = 'SIR',
    transitions = [
        ss.Transition(source=S, dest=I, rate=beta*I, name='infection'),
        ss.Transition(source=I, dest=R, dur=dur_inf, name='recovery'),
    ],
)

sim = ss.Sim(diseases=sir, solver='ode')
sim.run()
sim.plot()

These run as a compartmental model (an ODE). To run the same model as agents, give the number of agents, e.g. ss.Sim(sir, n_agents=5_000).

You can also run the same example from R:

library(starsim)

states("S I R")
sir <- Disease(
  infection = Transition(S, I, rate = 0.3 * I), # From S to I, at a rate of β times the fraction infectious
  recovery  = Transition(I, R, dur = days(10))  # From I to R, after 10 days on average
)

sim <- Sim(sir)
sim$run()
sim$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 v3. starsim init ai links them into your project, and starsim ai install --global sets them up for all your projects instead. You can also install them with other standard tools, such as uvx library-skills. 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.0rc5

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

Built distributions (wheels)

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

Total release size: 17.9 MB

Release files / starsim-4.0.0rc5.tar.gz

Download URL starsim-4.0.0rc5.tar.gz
Size 3.4 MB
Tags Source
SHA-256 checksum
How to use checksums
1f9a86d188bbdf7bf672965904cd540713ed58342c3ef146c4ea657e04a59004
BLAKE2b-256 checksum
How to use checksums
e85792e518df11b2716df5e7d103e59adcc566364a1ec2a028b98675d2cb3252
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 19, 2026.

Transparency log

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

Download URL starsim-4.0.0rc5-cp312-abi3-win_arm64.whl
Size 2.8 MB
Tags CPython 3.12 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
5ffb8442c02b43b9eefc4dbcf122c4035c6f30955579f0b3c93f7fc0e33d67b2
BLAKE2b-256 checksum
How to use checksums
620ac76a4d68e0175bd3e79321692e804998b45526666938966a1449e50f4370
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 19, 2026.

Transparency log

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

Download URL starsim-4.0.0rc5-cp312-abi3-win_amd64.whl
Size 2.9 MB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
9499e635215941598b75b102ba88a545d8bdf7f79a4e1e45d42b5fc72e0b4bc6
BLAKE2b-256 checksum
How to use checksums
1f2d81c9dfa45884b48966de35c4a4da3b3aca0a6a6797df67ba46f14838b1ff
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 19, 2026.

Transparency log

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

Download URL starsim-4.0.0rc5-cp312-abi3-manylinux_2_28_x86_64.whl
Size 3.0 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
0c7962cc517a0f8268e739d318b17185810c1f0cd1783618a5e68a518589f404
BLAKE2b-256 checksum
How to use checksums
98f645a367293f65e41bf76dd2de33405ec878f9e3e2226a29e8e9a36b5d0b8a
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 19, 2026.

Transparency log

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

Download URL starsim-4.0.0rc5-cp312-abi3-manylinux_2_28_aarch64.whl
Size 2.9 MB
Tags CPython 3.12 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
6b3b9c4634a074a251474502c23d60f6484a903191930fc0b02d2de0aee9e947
BLAKE2b-256 checksum
How to use checksums
aab4e475872b9264a2fc69893231716f43b7164eeaabfa4b165739b9e491c128
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 19, 2026.

Transparency log

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

Download URL starsim-4.0.0rc5-cp312-abi3-macosx_11_0_arm64.whl
Size 2.9 MB
Tags CPython 3.12 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ce78b79a2591c5a118faf5b568f6ec70448de6947db990c63a374f7c72a0d590
BLAKE2b-256 checksum
How to use checksums
8c48a738f608fe0b982fd900052b664fa2573f7bfb6badb7af20347063e38013
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 19, 2026.

Transparency log

Security for starsim 4.0.0rc5

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.0rc5.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 19, 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