Coronavirus Spread Explained in Layman’s Terms (Very Simple Python Simulation)

Ara Mambreyan
8 min readMar 20, 2020

If Leonardo Da Vinci was alive today and saw Mona Lisa wearing a surgical mask, he probably would have been shocked… and stolen the mask for himself!

Jokes aside, the Coronavirus outbreak has already caused lots of suffering. It has the potential to become one of the deadliest pandemics ever. Many estimates predict millions of deaths by the end of 2020.

What causes me unnerve is the number of people, especially politicians, who do not take this seriously. For instance, this morning I saw a supposed “professor” on national Russian TV say we should not do anything about this pandemic because seasonal flu kills more people than COVID19 has. Later in the afternoon, I heard of my acquaintance throwing a large-scale party…

So I spent the last two days writing a simulation in Python (a programming language) to hopefully explain what actually is going on.

Should we care at all? Is seasonal flu more dangerous? Why do we need to self-isolate?

Photo by Kelly Sikkema on Unsplash

Average Rate

What I call average rate, epidemiologists call basic reproduction number. Barring some technicalities, all it really means is how many people catch the virus from an infected person when nobody developed an immunity.

For instance, if you are sick and infect your girlfriend, your tennis coach and the bus driver, you infect 3 people in total.

As of now, it’s not clear what’s the average rate for COVID19. Most reports quote it as somewhere between 2–4. So I assumed it’s 3 initially. Why do I mention initially?

Well, because when the number of cases rises, governments start imposing bans — and sometimes complete lockdowns — and people start self-isolating.

The average rate starts off high but eventually reaches some number which I call the final average rate.

Average Rate Decreases until Convergence

This number depends on how strongly governments impose bans and the social responsibility of its citizens; when the latter is strong, the final average rate is lower (people spread the virus in smaller numbers).

I compared the spread and number of deaths from the final average rate in my model. (We will come to it in a bit).

The above figure shows the average rate’s dependence on the number of active cases in my model. It makes sense: when the active cases are large, governments impose stronger bans, people start to panic and stay at home.

Model

NOTE: Skip this part and move to “Results” section if you don’t want to understand the technical details of the model.

We start with 3 infected people and ignore incoming and outgoing cases (assume closed borders) and only focus on the spread of the virus inside the country. Here are the most important parameters I used in the model.

Parameters

Initial Average Rate = 3
Death Rate = 3.0%
Population = 3,000,000 (Armenia)
Healthcare Capacity = 5 bed for 1000 people
Percentage of Infected People who need Serious Medical Care = 14%
Percentage of Infected People who Develop Immunity = 80%

Note that I used Armenia’s population but all the results are qualitatively the same!

We also vary the final average rate and find the dependence for different values.

Parameters from the Python Code. (NOTE: If this confuses you, ignore it).

The model is simple.

On any given day, we have new daily cases. To calculate this, we use the current day’s average rate to first find the probability someone gets infected — this is simple to do. We then multiply this fraction by the number of people who can still get infected — the number of people who are not deceased, have not developed perfect immunity and are not sick.

We also have people who either die or recover. I assume that people who got sick exactly 14 days ago either die or recover. To calculate which fraction dies, I use the recovery rate. However, if the number of people who need medical care is higher than the medical capacity, the fraction of deaths is higher than the death rate of 3.0%.

(NOTE: Don’t worry if you are lost here. I tried to be concise but if you are not a math enthusiast it would be difficult to see what’s going on.)

The code for it is in github below.

Results

The picture below shows the results for different values of final average rate.

Intuitively speaking this makes sense. Initially, the number of active cases rises exponentially. You infect some people, they themselves infect others and so on: it’s like a chain reaction. When the number of cases grows too large, many people develop immunity towards the virus and do not get reinfected.

Looking at the plot, it’s clear that with stronger social distancing, the peak (highest value) of the curve is lowered and the curve is delayed. (You may have heard “flattening” or “spreading out” the curve. This is exactly what happened here). Why do we care about flattening the curve?

Lowering Peak

Unfortunately, there are a limited number of doctors and nurses so treating every patient is difficult. The black horizontal line in the graph is the healthcare capacity. The higher the peak is, the more people will be unable to get adequate treatment. (NOTE: the black line’s position is arbitrary. I simply put it there to illustrate my point. In reality, it’s much lower than that.)

This is what happened in Wuhan when the death rate was close to 20% and is what’s happening now in Italy. Hospitals are overwhelmed and patients who need treatment are left out. (We will examine the effects of the healthcare capacity shortly).

Photo by Macau Photo Agency on Unsplash

Delaying Peak

1. It gives us time to find the vaccine. Many companies are already working towards the vaccine so delaying the peak by as much as possible gives us a higher chance of finding the vaccine before many deaths happen.

2. It would give more time for researchers to understand the virus and hence prepare better guidelines and possible treatments.

3. By delaying the peak, governments have time to quickly increase the healthcare capacity. In fact, there are many hotels in the UK that are already being transformed into hospitals. In Armenia, they are also making a building for coronavirus patients.

The Outbreak Is Only Just Starting

Remember that “professor” on National TV in Russia and stuff?

Let’s check where on the graph we are. As of 19 March, Armenia has 122 confirmed cases. The below graph is the zoomed-in version of the above one. We place our “WE ARE HERE!!!” around x = 3 weeks and y = 120 confirmed cases.

Note that most countries are in a similar position. Let’s zoom out a bit more.

Hmmm… seems like we have a long way to go. Let’s zoom out just a little bit more.

Okay, we are there!

The outbreak is only just beginning. Comparing the number of deaths NOW to flu is silly because most deaths are going to happen in the future.

Saying it has fewer deaths than seasonal flu is like saying “Summer in 2020 had fewer days than Winter.” Yeah. Because Summer is yet to come.

But in the case of the virus, it’s not summer that’s coming.

Number of Deaths

What we really care about is the number of deaths and not the number of active cases. So let us plot the dependence of the number of deaths depending on other parameters.

Final Average Rate

From the above plots, it is clear that lower values of final average rate lower the active cases and therefore should lower the number of deaths too.

Here is the plot of the number of deaths in a year from the final average rate. One year is approximately the expected time until we find a vaccine so it makes sense to only track the number of deaths for only one year.

As expected, when social distancing is strong the number of deaths plummets massively. In other words, if everyone cut their social interactions by 3 — making the final average rate = 1.0 — the number of deaths would decrease by more than 50x !!!

Also, note that if strong action is not taken and the rate is, say, 1.2 the number of deaths equals about 30,000 which is 1% of the entire population of Armenia.

Percentage of Infected People who Develop Immunity

Let’s now check the dependence of the number of deaths from the fraction of people who develop full immunity. This is out of our control but is still important to understand.

As we expect, the higher the fraction is the lower are the number of deaths. In the critical case of only 10% of people developing full immunity, the number of deaths rises to 500,000. (NOTE: don’t be scared. 10% is very unlikely and I fixed the final average rate = 1.4 which is worse than what we can achieve by self-isolation).

Healthcare Capacity

Let’s now check how much the healthcare capacity changes the number of deaths.

We see that the number of deaths decreases when the healthcare capacity increases. This is expected of course.

What does this mean for me?

Stay home.

Stay home.

Stay home.

It is important to stay home if you can do so. Avoid social contact. Don’t go to parties and say “coronavirus is not as deadly as the flu.”

Every data there is shows that it is.

Try to work from home if you can. Yes, an 18-month quarantine will not work — it will completely screw up the economy and people need to eat.

But some self-isolation will work! You don’t need to go to parties to have a good economy.

And, at least in my book, “being alive” beats “party all day all night, dawg”.

Final Remarks

The model is not to be used to predict or make decisions. As you may have noticed, I made lots of approximations that are not true in real life. This is a straightforward and simple model — the aim of which is to understand general patterns and tweak a few parameters here and there to see what happens.

In fact, for some values the model was unstable (did not work properly).

Machine Learning algorithms and simulations need to be used to understand the actual parameters, make more complex simulations and improve the underlying assumptions.

If this managed to change your mind, please share this article. Or at least use the arguments here to convince your friends to stay home.

--

--

Ara Mambreyan

Information Engineering, Cambridge (2021) | IPhO medalist 2x | 10M+ Views | National Basketball Champion 5x | SWE Summer Intern, Barclays (2019)