You are on page 1of 6

The Mathematics Behind Contagion

Christopher Coutts September 19th, 2011

What the hell is epidemiology? (And how do I pronounce it?)

Epidemiology is looking at health issues and how they may eect our society. Preventative medicine such as inoculations are a form of epidemiology. Basically, the point is to understand the risks and consequences of various diseases, viruses and health problems and try to minimize their impact on human beings as a whole. And its pronounced like if you welded the sux ology onto the end of epidemic but accidentally melted the c because you werent very careful and honestly, youre a doctor not a welder, godammit so why the hell are you doing this anyways? Moving on. One aspect of epidemiology is modeling how infectious diseases may spread. This is pretty important because knowing how quickly a certain pathogen (lets say smallpox) could decimate humanity gives us the ability to choose optimum inoculation techniques to minimize the number of deaths. However, we need a way to learn this information without actually infecting a test population with smallpox. That is called poor ethics.

Suck it up. This is for science.

This is where the math comes in. Using the magic of modelling, we can simulate a fake population of people and infect them with smallpox. We can do this because fake people dont have any rights. The best part is, we can do this as many times as we feel like without any consequences (except perhaps becoming social outcasts). So if we use slightly dierent tactics in each simulation and run 1000 dierent simulations, we can gure out how best to defeat smallpox.

The SIR model

The lm Contagion is a realistic interpretation of what would happen in the event of a pandemic. Several times during the lm, they mention this magical number called are-knot (or simply R0 ). It is described as the average number of healthy people a single infected person will make sick (Common u has R0 = 1, according to the lm). Calculating R0 is one reason why modelling is important. Now, before I can talk about R0 further I need to establish a model that we can work with. The simplest model for infectious diseases is called the SIR model. SIR stands for Susceptible Infected Recovered. It consists of three dierent equations, one for each of the three populations we are interested in. Susceptible refers to healthy people who may become infected with the virus. Infected is people who are sick. Recovered is a combination of people who have gotten better and are now immune OR people who have died. A dead person is recovered because dead people cant be sick. Thats math logic.

He looks ne to me

Before we can build the model, we need some rules for our model to play by. These are very important. The total population doesnt change. Basically, at any point during the simulation, we can add up our people who are susceptible, infected, and recovered (or dead) and that number will be equal to our original number of people. Nobody is born and no one is killed by anything that isnt our virus. This is due to the fast nature of the virus. The time it takes to kill people is much much faster than our own birth/death rate so it becomes negligable. If you add the change in each population, the sum is always zero. So, if three people leave the susceptible population, three people have to be added to the infected population. 3 + 3 = 0. We arent inventing people out of thin air. That would be rude. This next part is going to be scary if you arent familiar with calculus, like absolutely terrifying. It may even make you ill. But dont worry. Ill walk you through it best I can. The biggest hurdle will probably be notation, so lets go over this very clearly. S stands for our susceptible population. Likewise I and R are susceptible and recovered.

d Youre going to see a weird thing on the right hand side that looks like this dt . This dS is just a fancy math symbol that means CHANGE. So when you see dt = all that means is The change in the susceptible population is equal to. The same goes for dI dt and dR (but with infected and recovered). dt

(beta) is the rate that people become infected. (gamma) is the rate that infected people get better or die. Okay, I think were ready to put this model together now. Are you ready? Cause if youre not you can just stop reading for a bit. Go put on a pot of tea, read a bit of a book, or something and then come back. J-Just make sure youre ready okay? This is important. dS = SI, dt dI = SI I, dt dR = I dt

(1a) (1b) (1c)

Now, in plain simple English. The susceptible population always decreases (the change is always negative) because, in this model, once someone has been infected, they either die or become immune (SIS models have no immunity). That decrease is the infection rate times susceptible times infected. The SI term, indicates interaction ie. if one person is infected SI will be smaller than if 100 people are infected. In the real world, the infection will spread quickly if more people are sick. However, if I gets too big, S decreases so the overall change decreases. This would also happen in the real world. The infected term takes all of the susceptibles that are infected and loses people who get better or die and the recovered term is just that. You may have noticed that the important R0 term that Contagion kept mentioning is nowhere in this model. Well, it is. But only implicitly. Much like in Indiana Jones and the Raiders of the Lost Ark, were going to have to do some digging to nd the R0 term. DISCLAIMER: This next section will be a wee bit confusing if you dont know any calculus. To compensate, Ill try to keep the jokes low brow.

What does R0 mean and how do we nd it out?

Okay, things are going to get a little bit crazy in here. Here we go. First thing were gonna do, is divide our susceptable equation by our recovered. This will give us the ratio of change in susceptable to change in recovered. It looks like this
dS dt dR dt



Then we do a teensy bit of algebraic manipulation dS S = dR 3 (3)

Then we seperate our variables and integrate dS = dR, S ln(S) = R + C, R(t) S(t) = S(0) exp

(4a) (4b) (4c)

Our R0 is the term since this is our growth term. Notice how it can be inserted into our infected equation like so dI = (R0 S 1)I (5) dt 1 If R0 is greater than S then our dI equation is positive and an outbreak will occur. If it 1 is less than or equal to S there will be no virus. Thats enough nasty math stu for now. Lets have some fun.

Contagion (alternate title: Why Health Canada should employ me. NOW)

The standard SIR model is a bit too dull and simple and doesnt really give us that much information. Plus, in the lm Contagion, they tell you quite a bit about how the virus acts and the time frame that it acts in. Using this information, lets modify our standard model into something that would be suitable for the virus from contagion. Lets organize these. We want to be able to track deaths. So were going to split up the recovered equation into a dead and a cured equation. Let C be the cured population and X be the killed population. The death rate in the lm is between 20% and 30% so Ill take an average of 25%. Our initial susceptable population will be 6.6 billion and our initial infected will be 1. One of the characters in the lm is immune to the virus but its implied his immunity is rare. So Ill start o the cured population at 0.05% of 6.6 billion to simulate the people who can never get this virus. Initially, the virus has an R0 of two but then jumps to an R0 of four. Thats hard to do, so this model will keep the R0 at two for the entire time. For now. I might get bored and do it the tricky way too. Okay, so here is our new model

Excuse me miss. Can you tell me how many people will die given these conditions

dS dt dI dt dC dt dX dt

= 0.2SI = 0.2SI 0.025I 0.075I = 0.075I = 0.025I

(6a) (6b) (6c) (6d)

This is a little more complicated. Lets see what this looks like in graphical form. Since its just a simple model, notice how the susceptible population decreases very sharply to zero and likewise, the infected increases very sharpely. As well the worst of the virus has passed after only twenty days.
7000 6000 5000 4000 3000 2000 1000 0 1000 Susceptible Infected Recovered Dead

pop. (millions)

10 days



Holy shit. I just killed a billion people. This is why math is cool

At the end of it all, there is about 1 billion human beings killed. Thats one out of six. The lm never explicitly mentions the ratio of how many people will die because of the virus but they give enough information to gure it out. Calculating on the y in the theatre, I got roughly 1 in 30 would die due to the contagion virus. There are many factors that this model doesnt take into account that would decrease the amount dead. For one, the hyper-awareness that people had of the virus (to the point of hostility) would cause R0 to drop drastically. This model also has no spatial element to it. Essentially, we are cramming the entire population into one (probably very smelly) room. Of course more people will die. So, even if this simple example has its aws and isnt entirely accurate, there are still things we can learn from it.

What the hell could I possibly learn from that stupid (yet pretty looking) graph

Look at how quickly people become infected and how long it takes for them to get better. While it is sped up in this simulation, that phenomena plays out similiar in realistic situations. In fact, deaths continue long after the maximum of infected is reached. So, in the case of a real life pandemic, when people start dying, a large number of us may already be infected and there is nothing we can do about it. This is why we have panics like with SARS and the Avian Flu. We cant tell if its going to kill millions of people until it is far too late. Health ocials tend to err on the side of caution in these situations, which is always a good thing. Actually, the awareness caused by relentless media attention will reduce the contact number (R0 ) since people will wash hands more often and be more aware of when theyre coughing or when they get ill. So, just go back and look at that graph for a moment. See how much bigger and how much quicker the infected line grows compared to the death line. Now, next time health ocials are warning about a potential outbreak, dont slag them o. Seriously.


For more interesting reading about SIR models, I highly recommend the article When Zombies Attack! Mathematical Modelling of an Outbreak of Zombie Infection by Robert Smith?. Its quite a bit more math heavy than this but if you understood the basics here, you might get something out of it. Heres the URL

You might also like