You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-7Lines changed: 9 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,7 @@
1
1
# Python Corona Simulation
2
2
3
+

4
+
3
5
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.
4
6
5
7
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:
28
30

29
31
30
32
## 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).
32
34
33
-

35
+

34
36
35
37
See [simple_simulation.py](simple_simulation.py) for the code.
36
38
@@ -50,7 +52,7 @@ Reality is of course more complex. Let's incorporate increasing risks with age,
50
52
- when _not_ in medial treatment: mortality chance increases threefold.
51
53
- ***note*** that this affects the elderly disproportionally as their baseline risk is already higher to start with.
52
54
53
-
### Case: 'Business As Usual'
55
+
### Case 'Business As Usual'
54
56
55
57
See [simulation.py](simulation.py) for the code and settable parameters.
56
58
@@ -60,7 +62,7 @@ As you can see in the simulation still below, the healthcare system becomes comp
60
62
61
63

62
64
63
-
### Case: 'Reduced Interaction'
65
+
### Case 'Reduced Interaction'
64
66
65
67
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).
66
68
@@ -69,7 +71,7 @@ As you can see in this simulation, while at some point healthcare capacity was o
69
71

70
72
71
73
72
-
### Case: 'Lock-Down'
74
+
### Case 'Lock-Down'
73
75
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.
74
76
75
77
@@ -82,7 +84,7 @@ However, if the lock down is lifted and a new case is introduced, a potential de
82
84
83
85
In such a situation repeated lock-downs seem inevitable if the infection keeps returning.
84
86
85
-
### Case: 'Self-Isolation'
87
+
### Case 'Self-Isolation'
86
88
87
89
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.
88
90
@@ -106,7 +108,7 @@ The picture here is more complex, as factors such as population density and the
106
108
<imgalign="center"src="https://github.com/paulvangentcom/python_corona_simulation/blob/master/images/selfisolation_low_100r.png"alt="medium density graph"width="600">
107
109
108
110
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.
0 commit comments