← All animations

🦠 The SIR Epidemic Model

An epidemic, in three letters. Split a population into the Susceptible, the Infected, and the Recovered, write down how people flow between those buckets, and a single number — R₀ — decides whether the disease explodes or fizzles. Scroll through to integrate the equations, watch the curve peak and burn out, and see why "flattening the curve" matters.

1. The classic curves — S, I and R over time

Everyone starts Susceptible. A few are Infected and pass it on at rate β (beta) on contact; the infected Recover at rate γ (gamma). That's the whole model: dS/dt = −βSI, dI/dt = βSI − γI, dR/dt = γI. The infection curve grows, hits an epidemic peak, then burns out as susceptibles run low — leaving a slice never infected. The verdict is R₀ = β/γ: above 1 you get an outbreak, below 1 it dies away.

R₀ = 3.00 → outbreak peak 30% infected 6% never infected

2. Flatten the curve — the agent's-eye view

The same maths, played out by moving dots that collide and infect — an agent-based mirror of the equations. The graph below tracks the live counts against a hospital-capacity line. Toggle social distancing to slow contacts: it lowers the effective β, so the peak gets lower and later — flattened under capacity. The vaccination slider starts a fraction already immune (in R): once you clear the herd-immunity threshold = 1 − 1/R₀, the outbreak can't take off at all.

0% immune herd threshold 67% infected 0%

3. What the model is actually saying

Compartments & flows. Every person sits in exactly one box and moves one way only:

S →β·S·I I →γ·I R

The S→I flow is βSI: new infections need a susceptible and an infected to meet, so it scales with both populations. The I→R flow is γI: a fixed fraction of the infected recover each day, so 1/γ is the average days spent infectious. Because nobody is created or destroyed, S + I + R stays constant.

R₀, the basic reproduction number. R₀ = β/γ is the average number of people one infected person passes the disease to in a fully susceptible population.

  • R₀ > 1 — each case more than replaces itself → the infection grows into an epidemic that peaks then burns out.
  • R₀ < 1 — each case fails to replace itself → the outbreak fizzles.
  • An epidemic stops not when everyone is infected, but when susceptibles fall far enough that the effective R drops below 1 — which is why a chunk is never infected.

Herd immunity. If a fraction 1 − 1/R₀ is already immune (recovered or vaccinated), each new case meets too few susceptibles to spread, and the disease can't gain a foothold — protecting even the unvaccinated. With R₀ = 3 that threshold is 1 − 1/3 ≈ 67%; the more contagious the disease, the higher the bar.

Why flatten, not just shrink? Slowing transmission (distancing, masks) lowers β. That pushes the peak lower and later without necessarily changing how many get infected overall — but a lower, slower peak keeps simultaneous cases under hospital capacity, so the sick get care and fewer die. The area under the curve can be similar; the height is what overwhelms a health system.

Limitations. This bare SIR model assumes one well-mixed population where everyone contacts everyone equally, fixed β and γ, permanent immunity, and no births, deaths, travel, or latent (exposed) period. Real diseases need extensions — SEIR (an exposed stage), age/contact structure, waning immunity, spatial networks — but the simple version already captures the essential shape: grow, peak, burn out.