SIR Epidemic Model: How Diseases Spread and How Vaccination Stops Them

simulator beginner ~6 min
Loading simulation...
SIR Model: R0=2.5, herd immunity at 60%

With R0=2.5 and gamma=0.1, the SIR model predicts a peak infection of approximately 20% of the population and a herd immunity threshold of 60%. Vaccinating above this threshold prevents epidemic spread.

Formula

dS/dt = -beta * S * I / N
dI/dt = beta * S * I / N - gamma * I
dR/dt = gamma * I
R0 = beta / gamma
Herd immunity = 1 - 1/R0

The Mathematics of Epidemics

In 1927, Kermack and McKendrick published a landmark paper that laid the mathematical foundation for understanding how infectious diseases spread through populations. Their SIR model remains one of the most important frameworks in epidemiology, dividing any population into three groups: Susceptible (those who can catch the disease), Infected (those currently ill and contagious), and Recovered (those who have gained immunity).

The Reproduction Number R0

The single most important number in epidemiology is R0, the basic reproduction number. It represents how many people one infected person will infect on average in a fully susceptible population. The transmission rate beta and recovery rate gamma together determine R0 = beta/gamma. When R0 > 1, each case generates more than one new case and the epidemic grows. When R0 < 1, the outbreak shrinks and dies out.

Herd Immunity

One of the most powerful insights from the SIR model is the concept of herd immunity. You do not need to vaccinate everyone to stop an epidemic — you just need to vaccinate enough people that the effective reproduction number drops below 1. The critical threshold is 1 - 1/R0. For a disease with R0 = 2.5, this means vaccinating 60% of the population protects everyone, including those who cannot be vaccinated.

Try It Yourself

Adjust R0 and watch the epidemic curve change shape. Then add vaccination and observe how crossing the herd immunity threshold (shown as a dashed line) completely suppresses the outbreak. The animated dot grid shows the disease spreading as a visible wave through the population.

FAQ

What is the SIR model?

The SIR model divides a population into three compartments: Susceptible (S), Infected (I), and Recovered (R). It describes how individuals move from S to I (infection) and from I to R (recovery) using differential equations. First formalized by Kermack and McKendrick in 1927.

What is R0 (R-naught)?

R0 is the basic reproduction number — the average number of secondary infections caused by one infected individual in a fully susceptible population. If R0 > 1, the epidemic grows exponentially. If R0 < 1, it dies out. COVID-19 had R0 of approximately 2-3, measles about 12-18.

What is herd immunity?

Herd immunity occurs when enough of the population is immune (through vaccination or prior infection) that the disease can no longer spread effectively. The threshold is 1 - 1/R0. For R0=2.5, this is 60% — meaning if 60% are immune, even the remaining 40% are protected.

How does vaccination affect epidemic dynamics?

Vaccination effectively removes individuals from the susceptible pool before the epidemic begins. When the vaccinated fraction exceeds the herd immunity threshold (1 - 1/R0), the effective reproduction number drops below 1 and the epidemic cannot sustain itself.

Sources

Embed

<iframe src="https://homo-deus.com/lab/network-science/epidemic-spreading/embed" width="100%" height="400" frameborder="0"></iframe>
View source on GitHub