Skip to content

Commit 4b0314a

Browse files
add intro gif, update readme
1 parent 7064d50 commit 4b0314a

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Python Corona Simulation
22

3+
![covid-19 sim!](images/covidsim.gif)
4+
35
After seeing [this article](https://www.washingtonpost.com/graphics/2020/world/corona-simulator/) in the Washington Post I started wondering how such simulations might be done in Python, and indeed if I could expand upon the idea to make them more realistic and fun to play with.
46

57
For a moment I thought about writing the simualation itself in pure Python, with matplotlib as visualisation tool. However it quickly became a design goal to be able to simulate large populations as well.
@@ -28,9 +30,9 @@ And keep in mind:
2830
![reality](images/george_e_p_box.jpg)
2931

3032
## Simple Infection Simulation
31-
As a first step I built a simulation of a population of randomly moving people. The people stay within the world bounds and each tick there's a 2% chance of them changing heading and speed. There's a 3% chance of becoming sick when getting close to an infected person, and a 2% chance of a fatal ending. [The video can be viewed here](videos/simple_simulation_01.mp4).
33+
As a first step I built a simulation of a population of randomly moving people. The people stay within the world bounds and each tick there's a 2% chance of them changing heading and speed. There's a 3% chance of becoming sick when getting close to an infected person, and a 2% chance of a fatal ending. [The video can be viewed here](http://www.paulvangent.com/corona/Simple_Simulation.mp4).
3234

33-
![image of the simulation](images/simple_simulation.png)
35+
![image of the simulation](images/horizontal/simple_simulation.png)
3436

3537
See [simple_simulation.py](simple_simulation.py) for the code.
3638

@@ -50,7 +52,7 @@ Reality is of course more complex. Let's incorporate increasing risks with age,
5052
- when _not_ in medial treatment: mortality chance increases threefold.
5153
- ***note*** that this affects the elderly disproportionally as their baseline risk is already higher to start with.
5254

53-
### Case: 'Business As Usual'
55+
### Case 'Business As Usual'
5456

5557
See [simulation.py](simulation.py) for the code and settable parameters.
5658

@@ -60,7 +62,7 @@ As you can see in the simulation still below, the healthcare system becomes comp
6062

6163
![image of simulation](images/lowcapacity_fastmovement.png)
6264

63-
### Case: 'Reduced Interaction'
65+
### Case 'Reduced Interaction'
6466

6567
The second simulation has the same settings, but to simulate people staying at home whenever possible and only going out when they have to, mobilty is greatly reduced. [See the video here](videos/Simulation_lowcapacity_limitedmovement.mp4).
6668

@@ -69,7 +71,7 @@ As you can see in this simulation, while at some point healthcare capacity was o
6971
![image of the simulation](images/lowcapacity_slowmovement.png)
7072

7173

72-
### Case: 'Lock-Down'
74+
### Case 'Lock-Down'
7375
Let's simulate a lock-down once 5% of the population is infected. Because some professions are considered critical and these people will still be on the move and in contact with other people. Besides that, because people are people, no lock-down will be perfect. To simulate this, we will make 90% of the people stop moving once locked-down, the remaining 10% will move with substantially reduced speed to simulate them being more cautious.
7476

7577

@@ -82,7 +84,7 @@ However, if the lock down is lifted and a new case is introduced, a potential de
8284

8385
In such a situation repeated lock-downs seem inevitable if the infection keeps returning.
8486

85-
### Case: 'Self-Isolation'
87+
### Case 'Self-Isolation'
8688

8789
Another approach is self-isolation: instructing people who have symptoms to stay at home. This was the initial approach the Dutch government had taken and is the approach in many countries that are not locked down. How effective is such a measure, especially given that not everybody will (or can) follow it? [It turns out people can be infectious to others without manifesting symptoms](https://edition.cnn.com/2020/03/14/health/coronavirus-asymptomatic-spread/index.html), which further complicates such a 'stay home if you feel ill' scenario.
8890

@@ -106,7 +108,7 @@ The picture here is more complex, as factors such as population density and the
106108
<img align="center" src="https://github.com/paulvangentcom/python_corona_simulation/blob/master/images/selfisolation_low_100r.png" alt="medium density graph" width="600">
107109

108110

109-
This illustrates the interaction between the density of the population (and thus how many people you come across per time unit), and the percentage of infectious people present in the population. This is what you would expect, as both of these factors affect your odds of running into an infected person. Notice how the plots show a clear 'tipping point': after 'n' number of infections, the virus spread starts accelerating. Reports have been going around that [even without symptoms you can still be contagious](https://edition.cnn.com/2020/03/14/health/coronavirus-asymptomatic-spread/index.html), and (remain contagious for quite some time after recovering](https://www.cbsnews.com/news/coronavirus-can-live-in-your-body-for-up-to-37-days-according-to-new-study/), which makes such a self-isolation scenario risky in the case of COVID-19.
111+
This illustrates the interaction between the density of the population (and thus how many people you come across per time unit), and the percentage of infectious people present in the population. This is what you would expect, as both of these factors affect your odds of running into an infected person. Notice how the plots show a clear 'tipping point': after 'n' number of infections, the virus spread starts accelerating. Reports have been going around that [even without symptoms you can still be contagious](https://edition.cnn.com/2020/03/14/health/coronavirus-asymptomatic-spread/index.html), and [remain contagious for quite some time after recovering](https://www.cbsnews.com/news/coronavirus-can-live-in-your-body-for-up-to-37-days-according-to-new-study/), which makes such a self-isolation scenario risky in the case of COVID-19.
110112

111113

112114

images/covidsim.gif

4.78 MB
Loading

0 commit comments

Comments
 (0)