SIR Epidemic Simulator: Compartment Model of Disease Spreading

simulator intermediate ~10 min
Loading simulation...
R₀ = 3.0 — 67% herd immunity threshold

With β=0.3 and γ=0.1, R₀=3.0. The epidemic infects roughly 94% of the population. Herd immunity requires 67% immune individuals to prevent sustained transmission.

Formula

dS/dt = −βSI/N (susceptible depletion)
dI/dt = βSI/N − γI (infection dynamics)
R₀ = β/γ (basic reproduction number)

Compartments of Contagion

In 1927, William Kermack and Anderson McKendrick published a landmark paper establishing the mathematical framework for epidemic modeling. Their SIR model partitions a population into Susceptible, Infected, and Recovered compartments, with flows governed by the transmission rate β and recovery rate γ. This elegant abstraction captures the essential dynamics of outbreaks from influenza to measles.

The Threshold Theorem

The model's most powerful prediction is the epidemic threshold: an outbreak can only occur if R₀ = β/γ exceeds 1. Below this threshold, each case generates fewer than one secondary infection, and the disease fades away. Above it, exponential growth ensues until susceptibles are sufficiently depleted. This threshold concept underpins all vaccination strategies — immunize enough people to push the effective reproduction number below 1.

Anatomy of an Epidemic Curve

A typical SIR epidemic follows a characteristic trajectory: slow initial growth while infections are rare, explosive exponential rise as chains of transmission multiply, a peak when susceptibles drop to N/R₀, and gradual decline as the virus runs out of fuel. The final size of the epidemic — the total fraction infected — depends only on R₀ and can be computed from a transcendental equation. For R₀ = 3, roughly 94% of the population is eventually infected.

From SIR to Modern Epidemiology

The basic SIR model has spawned an entire family of compartment models: SEIR adds an Exposed (latent) class, SIS allows reinfection, SIRV includes vaccination, and agent-based models capture individual heterogeneity. During the COVID-19 pandemic, extensions of these models guided lockdown policies, hospital capacity planning, and vaccine rollout strategies worldwide.

FAQ

What is the SIR model?

The SIR model divides a population into three compartments: Susceptible (S), Infected (I), and Recovered (R). Developed by Kermack and McKendrick in 1927, it describes how infectious diseases spread through a population using coupled ordinary differential equations.

What is R₀ and why does it matter?

R₀ (basic reproduction number) is the average number of secondary infections produced by one infected individual in a fully susceptible population. If R₀ > 1, an epidemic can occur; if R₀ < 1, the disease dies out. R₀ determines the herd immunity threshold: 1 − 1/R₀.

How accurate is the SIR model for real epidemics?

The basic SIR model captures the qualitative shape of many outbreaks but omits important factors: latent periods (SEIR), age structure, spatial heterogeneity, behavioral changes, and stochastic effects. It serves as a foundational framework extended by more complex models.

What determines the peak of an epidemic?

The infection peak occurs when the number of susceptibles drops to N/R₀. At this point, dI/dt = 0 because each infected person replaces itself with exactly one new case. The peak height depends on R₀ and the initial conditions.

Sources

Embed

<iframe src="https://homo-deus.com/lab/mathematical-biology/sir-compartment/embed" width="100%" height="400" frameborder="0"></iframe>
View source on GitHub