Simulating epidemics

Below you see a simulation of an epidemic. You can adjust the characteristics of the disease, and the characteristics of human behavior, to see how these affect the course of the epidemic. For example, consider an infection which lasts for 5 days, and which has a 3% probability of transmission. If people have 10 meetings per day, half of the global population will become infected. But if people reduced their interactions to just 6 per day, the epidemic could never even started!

Max infectious: . Min susceptible: .

This is an “SIR model”. “SIR” stands for “Susceptible, Infected, Recovered”. We have a constant population where each person is in one of these three states. Each day, some susceptible people become infected by meeting infectious people, and some infected people recover.

The SIR model is simplistic! Most obviously, it doesn’t account for location or networks; all meetings are between two random members of the global population. This is a limitation of all “compartmental models”. And the “states” in the SIR model are also simplistic. They don’t account for an incubation period, or for loss of immunity, or for carrier status, or for death (perhaps the most important state we care about!).

And yet the SIR model shows some important things about epidemics. It shows that the outcome is very sensitive to inputs. I mentioned one at the start: a moderate reduction in the number of meetings can be the difference between a pandemic and an isolated case. Similarly, if we reduced transmission probability from 3% to 2%, perhaps by wearing masks, the epidemic would never get started. Exponential growth is very sensitive to the exponent!

But the SIR model also shows that the epidemic won’t reach the whole population. As people become immune, the exponent drops below 1, because meetings between infected and susceptible people become less likely. In the simulation above, 40% of the population remain susceptible, but the epidemic died before it could reach them.

Discussion on Hacker News.
Tagged #programming, #epidemiology.
👋 I'm Jim, a full-stack product engineer. Want to build an amazing product and a profitable business? Read more about me or Get in touch!

More by Jim

This page copyright James Fisher 2020. Content is not associated with my employer. Found an error? Edit this page.