-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathneg-bi-dist.ipnyb
205 lines (205 loc) · 22.7 KB
/
neg-bi-dist.ipnyb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"from scipy import stats\n",
"from scipy.stats import nbinom\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"# Parameters\n",
"\n",
"# The number of oversea cases\n",
"OVERSEA_CASES = 8\n",
"# The daily number of international travellers out of WuHan's TianHe airport\n",
"# value of 3301 taken from Imperials's report\n",
"DAILY_OUTBOUND = 3301\n",
"# Catchement size of TienHe airport\n",
"# In other words how many people does the airport serve\n",
"# or the population of WuHan\n",
"# 11.08 million from 2018 official statistics, used by HKU\n",
"# CATCHEMENT = 11_080_000\n",
"# 19 million estimated population of WuHan metropolitan area, used by Imperial\n",
"CATCHEMENT = 19_000_000\n",
"# Detection window, how long from infection to hospitalized\n",
"# estimated incubation period of 6 days + 4 days of travelling =\n",
"DETECTION_WINDOW = 10"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"# probability that a random person in WuHan travels international on a given day\n",
"daily_international_probability = DAILY_OUTBOUND / CATCHEMENT\n",
"# probaility an infected person travels internationally while infected (before hospitalized)\n",
"p = daily_international_probability * DETECTION_WINDOW\n",
"k = OVERSEA_CASES"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"native estimate: 4604\n"
]
}
],
"source": [
"print(\"native estimate: %i\" % (OVERSEA_CASES / p))"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"mean: 4596\n"
]
}
],
"source": [
"# we can model the total number of cases in wuhan\n",
"# as a negative binomial distribution in terms of oversea cases\n",
"# see Imperial's report for more\n",
"mean, var, skew, kurt = nbinom.stats(k, p, moments='mvsk')\n",
"print(\"mean: %i\" % mean)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"95% CI: 1982 - 8290\n"
]
}
],
"source": [
"# 95% confidence interval\n",
"min_x, max_x = nbinom.interval(0.95, k, p)\n",
"print(\"95% CI: {:0.0f} - {:0.0f}\".format(min_x, max_x))"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"# we're only interested in the 95% CI, and only graph this range\n",
"x = np.arange(min_x, max_x)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"mode: 4022.0\n"
]
}
],
"source": [
"# find the mode\n",
"mode = max(x, key=lambda x: nbinom.pmf(x, k, p))\n",
"print(\"mode:\", mode)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAY0AAAD4CAYAAAAQP7oXAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh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Kt+lZWudB6/jaPtv7NirkAGNnAP9uhfH/3lOOxWTHstR4HKj7jgfAztdqMB/Ksn+u7uO4wCpTYrsW1+ucNHnWBEtsc4LD1u/AGrjugHP+8eT50GhGllFJ+C9XLU0oppRqBJg2llFJ+06ShlFLKb5o0lFJK+U2ThlJKKb9p0lBKKeU3TRpKKaX89v8BWBXaabMI0loAAAAASUVORK5CYII=\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# graph and save the plot\n",
"fig, ax = plt.subplots(1, 1)\n",
"ax.plot(x, nbinom.pmf(x, k, p), 'ko', ms=1)\n",
"ax.vlines(mean, 0, nbinom.pmf(int(mean), k, p),\n",
" color='r', lw=2, label='mean: %i' % mean)\n",
"ax.vlines(mode, 0, nbinom.pmf(int(mode), k, p),\n",
" color='b', lw=2, label='mode: %i' % mode)\n",
"ax.annotate(\"%i\" % min_x, xy=(min_x, nbinom.pmf(\n",
" int(min_x), k, p)-.00001), ha='center', va='top')\n",
"ax.annotate(\"%i\" % max_x, xy=(\n",
" max_x, nbinom.pmf(int(max_x), k, p)-.00001), ha='center', va='top')\n",
"\n",
"# add info to legend if you wish\n",
"# ax.vlines([], 0, 0, alpha=0, label=\"oversea cases: %i\" % OVERSEA_CASES)\n",
"# ax.vlines([], 0, 0, alpha=0, label=\"daily outbound: %i\" % DAILY_OUTBOUND)\n",
"# ax.vlines([], 0, 0, alpha=0, label=f\"population: {CATCHEMENT:,}\")\n",
"# ax.vlines([], 0, 0, alpha=0, label=\"detection window: %i\" % DETECTION_WINDOW)\n",
"\n",
"ax.legend(loc='upper left')\n",
"ax.set_ylim(bottom=0)\n",
"ax.set_xlim(left=0)\n",
"plt.savefig(\"pic.png\")\n",
"plt.show()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
}
},
"nbformat": 4,
"nbformat_minor": 4
}