applets.

Epidemic

← All apps

About Epidemic

How an infection spreads through a population, drawn as the maths that describes it. It is a model, not a forecast: the town, the people and the illness are made up, and the numbers are chosen to show the shapes clearly, not to describe any real disease.

TOWN: a few hundred people wander about a box. When someone who is ill meets someone who can catch it (comes within a short reach of them), it passes on with the chance you set, once per meeting. Each person is ill for the set number of days on average, then recovers and can't catch it again. Press RUN to watch it from the first three cases; it stops by itself when nobody is ill. Change how much people move, how many were vaccinated before it began, or how many stay at home. After a run the chart adds the SIR curve worked out from the run's own catching rate, so you can see how close the smooth maths comes to the dots. The seed fixes the town, so the same seed and settings give the same run every time.

CURVES: the SIR model itself. Slide R0 and the illness length and the curves follow; the dotted line is the herd-immunity line, and Cut meetings by draws a second, flatter outbreak beside the first.

R NUMBER: one case passes it to a random number of others, R on average, and each of those does the same. GROW draws one tree, generation by generation; RUN 1,000 TREES counts how many die out by themselves.

THE STORY

In London in 1854, the doctor John Snow marked the deaths in a cholera outbreak around Broad Street in Soho on a street map. They clustered around one water pump, and he persuaded the parish to take its handle off. The outbreak was already falling off by then, but the map became a famous early piece of evidence that cholera spreads through water.

Ronald Ross, who won the 1902 Nobel Prize for showing that mosquitoes carry malaria, went on to write the spread of malaria as equations. They showed that malaria could be stamped out by bringing mosquito numbers below a critical level, without killing every last one. In later papers, some with the mathematician Hilda Hudson, he worked on a general theory of how infections rise and fall.

In 1927 William Kermack, a chemist (blinded in a laboratory explosion three years before), and Anderson McKendrick, an army doctor, published "A contribution to the mathematical theory of epidemics". Its simplest case is the SIR model used here, and it showed two things: an outbreak can only take off if enough people can catch it, and it ends before everyone has had it, because it runs out of new people to reach.

The tree is a branching process, the maths Francis Galton and Henry Watson used in the 1870s for the chance that a family surname dies out.

HOW IT WORKS

SIR splits everyone into S (can catch it), I (ill and passing it on) and R (recovered, or removed). Each day the ill pass it on at rate β times the share who can still catch it, and recover at rate γ = 1 ÷ the days ill:
dS/dt = −β S I,   dI/dt = β S I − γ I,   dR/dt = γ I.
The page solves these in tenth-of-a-day steps (the Runge–Kutta method).

R0 ("R nought") = β ÷ γ, the number of people one case passes it to in a population where everyone can catch it. As people recover, fewer can catch it, and each case passes it to R0 × S. Once S falls below 1 ÷ R0 each case passes it to fewer than one person, so the number ill peaks and falls. That is the herd-immunity threshold, 1 − 1 ÷ R0 immune: 60% for R0 = 2.5. Vaccinate that share before it starts and it can't take off. The outbreak overshoots the threshold: the total who ever catch it, z, solves z = 1 − e−R0z (89% for R0 = 2.5).

Flattening the curve: cutting meetings lowers β and so R. The peak comes later and lower, and fewer people catch it in all. Below R = 1 it doesn't take off.

The town isn't told any of this. The dots only meet and roll dice. The page measures β from the run (new cases ÷ the S × I ÷ N "exposure" over the run) and draws the SIR curve with it. The dots differ from the smooth curves because people meet the same neighbours again (a crowd that has had it shields itself), and because small numbers are lumpy.

The tree: with "everyone alike" each case passes it to a Poisson-random number of people, average R. With "a few to many" most pass it to nobody and a few to lots (a negative binomial, dispersion 0.2), still R on average; some real outbreaks have looked like this. The chance a line dies out is the smallest q with q = G(q), where G is that distribution's generating function: for Poisson, q = eR(q−1). With R = 2 one case dies out by luck about 20% of the time; with several starting cases the chance is q to that power. Below R = 1 every tree dies out in the end.

FURTHER WATCHING AND READING

A picture of the maths, not a forecast: a made-up town and illness.

The town

People
Day
Ill now
Peak
Ever caught it
R0 measured
Herd line

The chart's dotted lines are the SIR model with the R0 these dots showed: the smooth maths against the lumpy town.