Intro to Simulations

2020-05-18 | Jin Pan |

Covid-19 has spread across our planet at a rapid pace, infecting 4.4 million+ people worldwide, with 1.4 million+ cases in the United States as of mid-May 2020. Until a vaccine is broadly administered, society must continue working together to control the infection rate.

There are hundreds of small decisions we make each day that collectively contribute to the infection rate - should I wear a mask? Should I go shopping solo? Should I wear my lucky socks? Do my decisions even matter?

While there are definitive answers to some questions (The CDC recommends everyone to wear a mask outdoors), others are harder to answer. To answer the harder questions, let’s simulate how a hypothetical virus spreads across a virtual population.

First, let’s simulate the Susceptible-Infectious-Recovered model. Green circles represent susceptible people, red infectious, and gray recovered. A susceptible person who gets too close to an infectious person will catch the disease.


The infected population initially grows rapidly but slows as the susceptible population shrinks, and eventually the virus runs out of people to infect. In this rough model, the pandemic is over with 70+% of the population infected.

We can improve this initial simulation by more realistically modeling

  1. Virus Spread
  2. Human Behavior

We will use the more realistic Susceptible-Exposed-Infectious-Recovered model, which introduces an exposed state, during which a person does not spread the disease. The WHO estimates that Covid-19’s exposed duration is one third the infectious duration, so we will use that ratio below.

Instead of spreading via contact, the disease will be spread through viral particles:

  • Infectious people emit viral particles by breathing, coughing, sneezing, etc
  • People continuously inhale viral particles; the more particles they breathe, the more likely they are to be exposed to the disease
  • Viral particles fade over time

We are not always trapped in a giant bouncy castle. Next, let’s simulate more realistic human behavior - shopping.