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

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

Built distributions (wheels)

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

Total release size: 18.0 MB

Release files / starsim-4.0.0rc6.tar.gz

Download URL starsim-4.0.0rc6.tar.gz
Size 3.4 MB
Tags Source
SHA-256 checksum
How to use checksums
2aabf1daee1557d1a5ebe8e608545c09d81fc4a64a661e3ef1b44c90c6a14aa1
BLAKE2b-256 checksum
How to use checksums
28b8c12b07d1e656a18d4027f6b96461659b5d732712744066094fa86ba1c215
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 21, 2026.

Transparency log

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

Download URL starsim-4.0.0rc6-cp312-abi3-win_arm64.whl
Size 2.8 MB
Tags CPython 3.12 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
f1117e036bb65769a81225278d468c95880e1f0852b47d59e5aebea05a884f9f
BLAKE2b-256 checksum
How to use checksums
9e68b5d62bb47e61ba3777bacb3927e28ec0b814befc41a1626169d4b8478feb
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 21, 2026.

Transparency log

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

Download URL starsim-4.0.0rc6-cp312-abi3-win_amd64.whl
Size 2.9 MB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
e1949e494ce23b13d3f89515994a544315fdb3dca45aab72bbb49ac353baa4e4
BLAKE2b-256 checksum
How to use checksums
9c83d2817686c9ff49b8ef3ad705cb59ca435ccf9d1386a9d7a940191f9bfd5a
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 21, 2026.

Transparency log

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

Download URL starsim-4.0.0rc6-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
9b239f43a6a7a8386d9db56f9d8b40ac60876502448f2d6b606246164623a10d
BLAKE2b-256 checksum
How to use checksums
fdc22623bfbb352c76a9cfea39d44f45456873c15c1adab4a1249257b7191711
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 21, 2026.

Transparency log

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

Download URL starsim-4.0.0rc6-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
506f6c956f0fcd0b09fbd7d4a7f4d048b53805fa541fbf68a7cf9104450555af
BLAKE2b-256 checksum
How to use checksums
855b90758b64543930a9b8fc3805e462ebd988ed19af94d3b2fc8f4abae9b8f5
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 21, 2026.

Transparency log

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

Download URL starsim-4.0.0rc6-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
77722152e6d6327c7dd67fdd02745c681e937d30a5b7c1fc5a587ee7fd30a9b3
BLAKE2b-256 checksum
How to use checksums
eadb1b71e5f64cd16ef030b88b3622e49d3ed7bc29a70e36fbba8a31c98884d8
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 21, 2026.

Transparency log

Security for starsim 4.0.0rc6

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.0rc6.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 21, 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