An epidemic in a box

A town of 1,000 people. Everyone is Susceptible, Infected or Recovered. Each infected person passes the illness to R₀ others over the time they are infectious, but only to people who are still susceptible. Slide R₀, vaccinate some of the town in advance, and watch what happens to the curve.

SusceptibleInfectedRecovered or vaccinatedsusceptible threshold 1/R₀

What's going on

New infections arrive at a rate proportional to how many infected people there are times how many susceptible people they can meet: new cases per day = (contact rate β) × S × I ÷ N. Infected people recover at rate γ = 1 ÷ (days infectious). The ratio β ÷ γ is R₀, the number of people one case infects in a town where everyone is susceptible. The demo nudges S, I and R forward in steps of a twentieth of a day, which closely follows the smooth equations; the sheet's one-day steps are a coarser version of the same thing.

At the start almost everyone is susceptible, so each case causes about R₀ more, and those cause R₀ more again: exponential growth. But every infection removes a susceptible person. Once the susceptible fraction drops below 1 ÷ R₀, each case causes fewer than one new case, and the number currently infected turns over. That is the peak of the red curve, and it happens exactly where the blue curve crosses the orange line.

Turn the sentence around and you have the herd immunity threshold: when at least 1 − 1 ÷ R₀ of the town is immune, the illness cannot grow. For R₀ = 3 that is two thirds; the readout shows it. At the peak the people who are no longer susceptible, infected plus recovered, make up exactly this fraction. Vaccination reaches it without anyone falling ill; an uncontrolled epidemic reaches it the hard way, and then overshoots, because the people infected around the peak go on to infect others.

Try R₀ = 3 with 0% vaccinated and note the final size, the total who ever caught it once the last case has recovered. Then set vaccination to 60%, just under the threshold, and to 70%, just over it. The epidemic does not simply shrink in proportion. It collapses, and the few remaining cases protect the unvaccinated too. That is what "herd" means.

Sheet: R₀ and herd immunity.