# Simulating an epidemic

## Метаданные

- **Канал:** 3Blue1Brown
- **YouTube:** https://www.youtube.com/watch?v=gxAaO2rsdIs
- **Дата:** 27.03.2020
- **Длительность:** 23:12
- **Просмотры:** 5,209,948

## Описание

Experiments with toy SIR models
Help fund future projects: https://www.patreon.com/3blue1brown
An equally valuable form of support is to simply share some of the videos.
Special thanks to these supporters: http://3b1b.co/sir-thanks
Home page: https://www.3blue1brown.com

Awesome fan-made interactives:
https://prajwalsouza.github.io/Experiments/Epidemic-Simulation.html
https://learningsim.itch.io/pandemic-spread-simulation

Simulations by Harry Stevens at the Washington Post:
https://www.washingtonpost.com/graphics/2020/world/corona-simulator/

Simulations by Kevin Simler at Melting Asphalt:
https://meltingasphalt.com/interactive/outbreak/

Excellent visualization of each country's current growth from Minutephysics and Aatish Bhatia:
https://www.youtube.com/watch?v=54XLXg4fYsc

Another good interactive to see what effect various parameters have on the shape of the curve:
http://gabgoh.github.io/COVID/index.html

If you want to hear a mathematician/epidemiologist's summary of COVID-19, I found this MSRI  talk very worthwhile:
https://youtu.be/MZ957qhzcjI

Marcel Salathé on Contact Tracing:
https://twitter.com/marcelsalathe/status/1242430736944201730

Thanks to these viewers for their contributions to translations
Hebrew: Omer Tuchfeld

------------------

These animations are made using manim, a scrappy open-source python library:  https://github.com/3b1b/manim

Code for this video:
https://github.com/3b1b/videos/blob/master/_2020/sir.py

Honestly, given that the code for that video is meant for demo purposes, and not meant to reflect the true data of COVID-19, if you want to apply these ideas to the current situation I'd recommend looking for more professional epidemiological modeling tools that are less centered around animations and pedagogy and more focused on accurate predictions.  For example, the Institute for Disease Modeling has a lot of models free for people to look at and play with.

---------------

Opening music:
Candlepower by Chris Zabriskie is licensed under a Creative Commons Attribution license (https://creativecommons.org/licenses/by/4.0/)
Source: http://chriszabriskie.com/divider/
Artist: http://chriszabriskie.com/

Other music by Vincent Rubinetti.
Download the music on Bandcamp:
https://vincerubinetti.bandcamp.com/album/the-music-of-3blue1brown

Stream the music on Spotify:
https://open.spotify.com/album/1dVyjwS8FBqXhRunaG5W5u

If you want to contribute translated subtitles or to help review those that have already been made by others and need approval, you can click the gear icon in the video and go to subtitles/cc, then "add subtitles/cc".  I really appreciate those who do this, as it helps make the lessons accessible to more people.

------------------

3blue1brown is a channel about animating math, in all senses of the word animate.  And you know the drill with YouTube, if you want to stay posted on new videos, subscribe: http://3b1b.co/subscribe

Various social media stuffs:
Website: https://www.3blue1brown.com
Twitter: https://twitter.com/3blue1brown
Reddit: https://www.reddit.com/r/3blue1brown
Instagram: https://www.instagram.com/3blue1brown_animations/
Patreon: https://patreon.com/3blue1brown
Facebook: https://www.facebook.com/3blue1brown

## Содержание

### [0:00](https://www.youtube.com/watch?v=gxAaO2rsdIs) Segment 1 (00:00 - 05:00)

I want to share with you a few simulations that model how an epidemic spreads. There have recently been a few wonderful interactive articles in this vein, including one in the Washington Post by Harry Stevens, and then another by Kevin Simler over at Melting Asphalt. They are great, you can play with them, they're very informative, I'll of course leave links in the description. After seeing those, I had a few more questions. Like if people stay away from each other, I get that that's going to slow down the spread. But what if despite mostly staying away from each other, people still occasionally go to a central location, like a grocery store or a school? Also, what if you're able to identify and isolate the cases? And if you can, what if a few slip through, say because they don't show symptoms so they aren't tested? How does travel between separate communities affect things? And what if people avoid contact with each other for a while, but then they kind of get tired and stop? We'll explore these questions and more, but first let's walk through how exactly these models will work. Each simulation represents what's called an SIR model, meaning the population is broken up into three categories, those who are susceptible to getting the disease, those who are infectious, and then those who have recovered from the infection, so people who are immune don't play into it. The way I've written these, for every unit of time that a susceptible person spends within a certain infection radius of someone with the disease, they'll have some probability of contracting it themselves, so we're using physical proximity as a stand-in for things like shaking hands, touching the same surface, kissing, sneezing on each other, all that good stuff. Then for each infectious person, after some amount of time they'll recover and no longer be able to spread the disease, or if they die they won't be able to spread it anymore, so as a more generic term, sometimes people consider the R in SIR to stand for removed. This should go without saying, but let me emphasize it at the start anyway. These are toy models, with a tiny population, inevitably falling far short of the complexities in real people and larger populations. I am not an epidemiologist, so I would be very hesitant to generalize any of the lessons here without deeper consideration. That said, I think it can be healthy to engage the little scientist inside all of us and take the chance to be experimental and quantitative, even if it's in a necessarily limited fashion, especially if the alternative is to dwell on headlines and uncertainty. We'll start things simple and layer on more complexity gradually. In these first few runs that you're looking at, everybody is simply meandering around the city in a kind of random walk, and the infection follows the rules we've laid out. So it doesn't look great, after not too long almost everybody gets infected. As a sanity check, what would you expect to happen if I double this radius of infection? You might think of this as representing more total interactions between people, or a more socially engaged society. It'll spread more quickly, of course, but how much? It's actually very drastic. Within a short time span, the majority of our little population is infected simultaneously. As another sanity check, what would you expect if we go back to the original infection radius, and then cut the probability of infection in half? Remember, the way this is running, for each day that a susceptible person is within that radius of an infectious person, they have some probability of becoming infected. By default I've set it to 20%, but this is the number we're now going to cut in half. You might think of this as better hand washing, better cough protection, and less face touching. As you might expect, it spreads out the curve. In fact it does this by quite a lot, which really illustrates how changes to hygiene have very large effects on the rate of spreading. The first of several key takeaways here that I'd like you to tuck away in your mind is just how sensitive this growth can be to each parameter in our control. It's not that hard to imagine changing your daily habits in a way that multiplies the number of people you interact with, or that cuts your probability of catching an infection in half, but the implications for the pace of the spread are huge. The goal is probably to reduce the total number of people who die, which is some proportion of this removed category in the end. That proportion is not a constant, though.

### [5:00](https://www.youtube.com/watch?v=gxAaO2rsdIs&t=300s) Segment 2 (05:00 - 10:00)

If you get to a point where the peak of the infection curve is too high, meaning there's a time when many people are all sick at once, that's the point when available healthcare resources are overwhelmed, which for a bad disease will increase the mortality rate. Now I don't know where you're from, but in most towns people don't actually spend their days drunkenly wandering around the city like this. Often there's a common destination, like a central market or a school. In our model, if we introduce some central spot like this that people regularly visit and then return from, it's… well, just look. One of the main things I was curious about is how to mitigate this effect, and that's something we'll examine in just a bit. Another feature we could include is to have a few separate communities with transit between them. Every day, each person will have some probability of traveling to the center of another community, and then going about their usual routine from there. All of that is our basic setup, so now the question is what actions help to stop this spread? What is by far most effective is to identify and isolate whoever is infectious, for example with good testing and quick responsiveness. In our simulations, once we hit some critical threshold of cases, we're going to start sending people to a separate location one day after they have the infection. This is of course a stand-in for whatever isolation would look like in the real world, it doesn't have to literally be transporting all the sick people into one sad box. Unsurprisingly, this totally halts the epidemic in its tracks. But what if when you're infected you have a 20% chance of not getting quarantined, say because you show no symptoms so you don't get tested, and you go about your day as usual? We're going to illustrate these people that have no symptoms using yellow circles instead of red. Obviously this will have a result somewhere between a total quarantine and doing nothing, but where on the spectrum would you predict it'll be? The peak number of simultaneous cases is only a little bit higher, but there is a very low long tail as it takes a much longer time to stamp out, resulting in about twice as many total cases. This gets more interesting when we do it in a setting with many communities and transit between them. Again, totally effective tracking in isolation stops the epidemic very quickly, but what would you predict is going to happen if now 20% of the infectious cases slip through that process? Again, I've set things to wait until a certain critical threshold of cases is hit before our little dot society kicks into gear and takes action. As a side note, it's a little interesting that even when all the parameters are the same, some runs take three times longer to reach this point than others. Before the law of large numbers kicks in, that pace of growth can have as much to do with the roll of the dice as it does with anything intrinsic to the disease itself. This leaky quarantining effort definitely flattens out the curve, but it is a much thicker tail and takes a much longer time to track down all the cases, with over half the population getting infected this time. Now, what would you predict if it was only 50% of the infectious cases that were isolated like this? If half the infectious people are getting quarantined, it doesn't mean that half the total population will end up with the disease. Because there are so many agents still out there spreading it, we end up with a situation that's only barely better than if nothing had been done at all. A second key takeaway here is that changes in how many people slip through the tests can cause disproportionately large changes to the total number of people infected. If we look back to the fact that quickly containing cases so early is so effective, it actually has an interesting corollary, which is that the most lethal diseases are in some sense less dangerous globally. Remember that the rule of this quarantine simulation is to send infectious people to a separate spot one day after they've been infected, but if the disease kills its host after one day, the model looks identical, it just has a much darker interpretation. It is terrible for those who get it, but it doesn't spread. It also means that the most dangerous viruses are the ones that kill some part of the population in the first place, while laying unnoticed and spreadable among others. Or worse yet, if they remain unnoticed and spreadable in everyone before eventually becoming lethal. One of the reasons that the SARS outbreak in 2002 was so well

### [10:00](https://www.youtube.com/watch?v=gxAaO2rsdIs&t=600s) Segment 3 (10:00 - 15:00)

contained is that just about everybody in this infectious population was showing symptoms, so they were much easier to identify and isolate. A more optimistic corollary of these quarantine simulations is how useful early treatment can be. If there exists an antiviral therapeutic that can move people out of this infectious category quickly, it has the same effect on the model as isolating those cases. But let's say you don't have widespread testing or antiviral therapeutics. Well, let's introduce a new parameter here, which is how much people try to avoid each other. Let's call it the social distance factor. In these animations, I'll apply it as a repulsive force between people, and have them glow yellow when they feel just a little too close to their neighbor. This has the sad but kind of cute effect that when our little agents are social distancing, they often end up trembling near the edge of their box. No isolation is perfect, though, so every now and then even those repulsed by each other will jiggle close enough to get infected. The point is that those interactions are much rarer. Let's take a look at four separate runs here. In each one of them, after we hit 50 cases, I'll turn on social distancing. But in the top left, we'll turn it on for everybody. In the top right, 90% of the population. In the bottom left, for 70% of the population, and in the bottom right, for only half the population. What would you predict is going to happen? As you might expect, when 100% of people avoid each other, the disease quickly goes away, entirely. And in all four cases, the presence of some kind of widespread social distancing definitely flattens out the curve. However, in terms of the ultimate number of cases, the run with 70% and even the one with 90% end up with a little less than half the population ultimately getting infected, which is only a tiny bit better than the one with 50%. That case with 90% of people repelling each other certainly takes longer to get there, but evidently a mere 10% of the population cheating adds enough instability to our system to keep the fire slowly burning for a long time. Again, I'll emphasize that these are toy models, and I leave it to the intelligence of the viewer to judge if the behavior of these little dots accurately reflects what social distancing would mean for you and your life. Someone fully sequestered in their home is not necessarily affected by the random jiggling of their neighbor, but then again, few of us genuinely live independently from everyone else. Insofar as these models aren't outlandish, the third key takeaway is that social distancing absolutely works to flatten the curve, but even small imperfections prolong the spread for a while. Now let's look at that setup with 12 communities and travel between them. By default I have it set so that every day each agent has a 2% chance of traveling to the center of a different community. Now let's try a run where once we hit 100 cases, we cut down that travel rate by a factor of 4, to only half a percent. The honest answer is that it depends. In some runs it doesn't make any difference, and the majority of every community gets it. Other times there are a couple communities that end up unscathed. In general, the earlier you turn on this effect, the more effective it is, but the takeaway here is that reducing contact between communities really has only a limited effect once those communities already have it, and as solutions go it's certainly not robust on its own. As a side note, when we run these simulations with larger cities, which has the effect that city centers act like concentrated urban hubs, you can see how as soon as the infection hits one of these urban centers, it very quickly hits all of them. And after that, it slowly spreads to the edges of each community. Let's take a moment to talk about how to quantify this spread. Consider one person with the disease, and then count how many people they infect while they have it. The average for this count across everybody who's been sick is known as the effective reproductive number, or R. A more commonly discussed number is R-naught, which is the value of R in a fully susceptible population, like at the very beginning.

### [15:00](https://www.youtube.com/watch?v=gxAaO2rsdIs&t=900s) Segment 4 (15:00 - 20:00)

This is known as the basic reproductive number. You may have noticed I have this little label on our simulations, and the way it's being calculated is to look at each individual who's currently infectious, count how many people they've infected so far, estimate how many they're going to infect in total based on the duration of the illness, and then average those numbers. For example, in our first default simulation with no added spices, R is around 2. 2 at the highest part of the growth phase, before falling down as the population becomes saturated. By contrast, when we doubled the infection radius, R was as high as 8! This factor has a huge effect on the growth rate. It should kind of make sense that it jumped up as high as 8, though. When you double that radius, there's about 4 times as many people inside it to infect. When we chopped the infection rate in half, it hovered around the 1. 3 to 1. 7 range. While R is greater than 1, the infection is growing exponentially, and it's at that point that it's known as an epidemic. When it holds steady around 1, that's when a disease is called endemic, and less than 1 means it's on the decline. For comparison, R-naught for COVID-19 is estimated to be a little above 2, which is also around what the mean estimate for R-naught was during the 1918 Spanish flu pandemic. The seasonal flu by comparison is much lower, around 1. 3. In the travel case, as soon as we turn on social distancing and shut down travel, you can see R quickly drop down from 2. There's a little bit of a lag between the change we make to the model and the value of this number, since it's calculated based on current infectious cases, which might have existed prior to the method being put in place. Like I said at the start, one of the things I was most curious about is the effect of some kind of shared central location, like a market or a school. When I introduce such a destination for our little dots, R0 jumps as high as 5. 8. This might be a little unfair, since it puts everyone right in the same spot, and given that we're using physical proximity as a stand-in for things like shaking hands or kissing, we should maybe acknowledge that people going to the same school or grocery store are not as likely to spread an infection as, say, close friends or people living in the same house. To account for this, let's conservatively cut the probability of infection per day in half. This does indeed cut R0 in half, but the effect of a central market remains dramatic. Now let's try a run where after some threshold is hit, we turn on social distancing, but people still go to that central location the way they did before. You may notice that some of our little dots seem to have escaped their little cage, which was not supposed to happen, but I'm going to make the conscious choice not to fix that. It's like they all looked at the chaos inside and just went, nope, I'm out, I don't want any part of that. Living in the Bay Area during a shelter-in-place order, I can confirm that this is how some people react. Wandering dots aside, let me show you how this graph compares to the control case where we did nothing, and how it compares to what would have happened if in addition to repelling from each other, all the dots also stopped going to that central location. The peak of the infection curve is a little lower than the control, but in terms of the total number of cases, keeping that central location active really defeats the effects of otherwise social distancing. Now let me ask you to make a prediction. What do you think will be more effective? If on top of that social distancing effect, we decrease the frequency with which people go to that central spot, maybe by a factor of 5, or if we chop the probability of infection down by another factor of 2, for example meaning people are super extra cautious about washing their hands and not touching their face. The simulation on the left requires our dots to very heavily alter their daily routines, whereas on the right our dots can mostly continue their usual habits, but are much more conscious of hygiene. They're actually nearly identical, which surprised me, given that one of them is a fivefold decrease and the other is twofold. I guess it goes to show that the effect of hygiene, which is maybe easier said than done, really goes a long way. Of course, it doesn't have to be an either-or. Our goal with these experiments is to look at the effects of one change at a time. If you're curious, here's what it looks like when we apply social distancing, we restrict the rate that people go to the central location, and we also lower the infection rate all at once. This combination is, indeed, very effective.

### [20:00](https://www.youtube.com/watch?v=gxAaO2rsdIs&t=1200s) Segment 5 (20:00 - 23:00)

But I want to emphasize again how the most desirable case is when you can consistently identify and isolate cases. Even in this central market simulation, which left unchecked gives a huge conflagration, being able to do this effectively still halts the epidemic, and our little dots don't even have to be repelled by each other or stop their trips to the central spot. In real epidemiology, by the way, it gets way more sophisticated than this, with tactics like contact tracing, where you not only identify and isolate known cases, but you do the same for everyone who's been in contact with those cases. Given the time I'm posting this, I imagine there's some expectation for it to be a PSA on social distancing. But to be honest, that's not really my own main takeaway. To be clear, when it's needed, like it is now, social distancing absolutely saves lives, and as we saw earlier, when people cheat or when they continue to regularly meet at a central spot, it has a disproportionate effect on the long-term number of cases. The uncomfortable truth, though, is that while the disease still exists, as soon as people let up and they go back to their normal lives, if nothing is in place to contain the cases, few though they might be, you'll just get a second wave. After making all of these, what I came away with more than anything else was a deeper appreciation for disease control done right, for the inordinate value of early widespread testing and the ability to isolate cases, for therapeutics that treat these cases, and most importantly, for how easy it is to underestimate all that value when times are good. I'm writing this during a pandemic, when some viewers may be able to identify a little too well with the trembling dots retreating to the edge of their box. But in the future, many people will be watching this during a pandemic that never was, a time when a novel pathogen that could have spread widely if left unchecked was instead swiftly found and contained. Those would-be pandemics never make it into the history books, which is maybe why we don't value the heroes behind them the way we should. Living in a world with widespread travel and vibrant urban centers does make fighting the spread of a disease an uphill battle, that's absolutely true. But that same level of connectedness means that ideas spread more quickly than ever, ideas that can lead to systems and technologies that nip these outbreaks in the bud. It won't happen on its own, and it's clear that we sometimes make mistakes, but I'm fundamentally optimistic about our ability to learn from those mistakes. As you might imagine, these videos require a lot of hours of effort. I don't do any ad reads at the end, and YouTube content related to the current pandemic seems to be systematically demonetized, so I just want to take this chance to say a particularly warm thank you to those who support them directly on Patreon. It really does make a difference.

---
*Источник: https://ekstraktznaniy.ru/video/16203*