Skip to content

Commit 25563ad

Browse files
author
Longye Tian
committed
update the implementation, experiments sections and update figures labels
1 parent 1ce42bb commit 25563ad

1 file changed

Lines changed: 31 additions & 14 deletions

File tree

lectures/sir_model.md

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,13 @@ def F(x, t, R0=1.6):
189189

190190
Note that `R0` can be either constant or a given function of time.
191191

192-
The initial conditions are set to
192+
The initial conditions are calibrated to a population of 330 million.
193+
194+
The value $i_0 = 10^{-7}$ represents 33 initially infected people, while
195+
$e_0 = 4i_0$ represents 132 exposed people.
196+
197+
Setting $s_0 = 1 - i_0 - e_0$ assigns the remaining population to the
198+
susceptible state and sets the initial removed fraction to zero.
193199

194200
```{code-cell} ipython3
195201
# initial conditions of s, e, i
@@ -204,7 +210,7 @@ In vector form the initial condition is
204210
x_0 = s_0, e_0, i_0
205211
```
206212

207-
We solve for the time path numerically using odeint, at a sequence of dates
213+
We solve for the time path numerically using `odeint`, at a sequence of dates
208214
`t_vec`.
209215

210216
```{code-cell} ipython3
@@ -241,7 +247,7 @@ We calculate the time path of infected people under different assumptions for `R
241247

242248
```{code-cell} ipython3
243249
R0_vals = np.linspace(1.6, 3.0, 6)
244-
labels = [f'$R0 = {r:.2f}$' for r in R0_vals]
250+
labels = [f'$R_0 = {r:.2f}$' for r in R0_vals]
245251
i_paths, c_paths = [], []
246252
247253
for r in R0_vals:
@@ -253,13 +259,15 @@ for r in R0_vals:
253259
Here's some code to plot the time paths.
254260

255261
```{code-cell} ipython3
256-
def plot_paths(paths, labels, times=t_vec):
262+
def plot_paths(paths, labels, ylabel, times=t_vec):
257263
258264
fig, ax = plt.subplots()
259265
260266
for path, label in zip(paths, labels):
261-
ax.plot(times, path, label=label)
267+
ax.plot(times, path, lw=2, label=label)
262268
269+
ax.set_xlabel('days')
270+
ax.set_ylabel(ylabel)
263271
ax.legend(loc='upper left')
264272
265273
plt.show()
@@ -268,7 +276,7 @@ def plot_paths(paths, labels, times=t_vec):
268276
Let's plot current cases as a fraction of the population.
269277

270278
```{code-cell} ipython3
271-
plot_paths(i_paths, labels)
279+
plot_paths(i_paths, labels, ylabel='current cases (fraction of the population)')
272280
```
273281

274282
As expected, lower effective transmission rates defer the peak of infections.
@@ -278,7 +286,7 @@ They also lead to a lower peak in current cases.
278286
Here are cumulative cases, as a fraction of population:
279287

280288
```{code-cell} ipython3
281-
plot_paths(c_paths, labels)
289+
plot_paths(c_paths, labels, ylabel='cumulative cases (fraction of the population)')
282290
```
283291

284292
### Experiment 2: changing mitigation
@@ -301,7 +309,11 @@ This is due to progressive adoption of stricter mitigation measures.
301309
The parameter `η` controls the rate, or the speed at which restrictions are
302310
imposed.
303311

304-
We consider several different rates:
312+
Since $t$ is measured in days, $\eta$ is measured per day, and its reciprocal,
313+
$1/\eta$, is the adjustment period.
314+
315+
The values below correspond to adjustment periods of 5, 10, 20, 50, and 100
316+
days:
305317

306318
```{code-cell} ipython3
307319
η_vals = 1/5, 1/10, 1/20, 1/50, 1/100
@@ -314,8 +326,10 @@ This is what the time path of `R0` looks like at these alternative rates:
314326
fig, ax = plt.subplots()
315327
316328
for η, label in zip(η_vals, labels):
317-
ax.plot(t_vec, R0_mitigating(t_vec, η=η), label=label)
329+
ax.plot(t_vec, R0_mitigating(t_vec, η=η), lw=2, label=label)
318330
331+
ax.set_xlabel('days')
332+
ax.set_ylabel('$R_0$')
319333
ax.legend()
320334
plt.show()
321335
```
@@ -335,15 +349,18 @@ for η in η_vals:
335349
These are current cases under the different scenarios:
336350

337351
```{code-cell} ipython3
338-
plot_paths(i_paths, labels)
352+
plot_paths(i_paths, labels, ylabel='current cases (fraction of the population)')
339353
```
340354

341355
Here are cumulative cases, as a fraction of population:
342356

343357
```{code-cell} ipython3
344-
plot_paths(c_paths, labels)
358+
plot_paths(c_paths, labels, ylabel='cumulative cases (fraction of the population)')
345359
```
346360

361+
Faster implementation of mitigation mainly delays the infection peak, with a
362+
smaller effect on its height.
363+
347364
## Ending lockdown
348365

349366
The following replicates [additional results](https://drive.google.com/file/d/1uS7n-7zq5gfSgrL3S0HByExmpq4Bn3oh/view) by Andrew Atkeson on the timing of lifting lockdown.
@@ -383,7 +400,7 @@ for R0 in R0_paths:
383400
Here is the number of active infections:
384401

385402
```{code-cell} ipython3
386-
plot_paths(i_paths, labels)
403+
plot_paths(i_paths, labels, ylabel='active infections (fraction of the population)')
387404
```
388405

389406
What kind of mortality can we expect under these scenarios?
@@ -398,14 +415,14 @@ This is the cumulative number of deaths:
398415

399416
```{code-cell} ipython3
400417
paths = [path * ν * pop_size for path in c_paths]
401-
plot_paths(paths, labels)
418+
plot_paths(paths, labels, ylabel='cumulative deaths')
402419
```
403420

404421
This is the daily death rate:
405422

406423
```{code-cell} ipython3
407424
paths = [path * ν * γ * pop_size for path in i_paths]
408-
plot_paths(paths, labels)
425+
plot_paths(paths, labels, ylabel='deaths per day')
409426
```
410427

411428
Pushing the peak of curve further into the future may reduce cumulative deaths

0 commit comments

Comments
 (0)