Skip to content

Commit 5ad4750

Browse files
committed
cleaning up viz.qmd
1 parent 7ddc61e commit 5ad4750

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

scratch/viz.qmd

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,32 @@ import matplotlib.pyplot as plt
1111
1212
```
1313

14+
# Example calculation with 2 groups
15+
16+
```{python}
17+
import numpy as np
18+
n = np.array([200, 800])
19+
beta = np.array([[10, 0.1],[.1, 1]])
20+
n_vax = np.array([100, 0])
21+
ve = 1.0
22+
23+
s_i = n / n.sum()
24+
s_vax = (n - n_vax * ve) / n
25+
26+
R_vax = beta * s_i * s_vax
27+
e = np.linalg.eig(R_vax)
28+
i = np.argmax(np.abs(e.eigenvalues))
29+
30+
value = e.eigenvalues[i]
31+
vector = e.eigenvectors[:, i]
32+
vector /= sum(vector)
33+
34+
value
35+
vector
36+
```
37+
38+
# 4 group model
39+
1440
```{python}
1541
# parameters (core, kids, travelers, general)
1642
n = np.array([0.1, 0.45, 0.05, 0.4]) * 1000000
@@ -50,7 +76,7 @@ test2
5076
```{python}
5177
# test that equal pop sizes result in bigger Re
5278
n_equal = np.array([0.25, 0.25, 0.25, 0.25]) * 1000000
53-
test3 = ngm.simulate(n_equal, n_vax_0, K, p_severe, ve)
79+
test3 = ngm.simulate(n_equal, n_vax_0, beta, p_severe, ve)
5480
test3
5581
5682
```
@@ -72,7 +98,7 @@ df_n_vax = pd.DataFrame(n_vax_values, columns=["Core", "Kids", "Travelers", "Gen
7298
results = []
7399
for index, row in df_n_vax.iterrows():
74100
n_vax = row.values
75-
result = ngm.simulate(n, n_vax, K, p_severe, ve)
101+
result = ngm.simulate(n, n_vax, beta, p_severe, ve)
76102
results.append({
77103
"Total Doses": total_doses_range[index],
78104
"Re": result["Re"],
@@ -109,7 +135,7 @@ df_n_vax = pd.DataFrame(n_vax_values, columns=["Core", "Kids", "Travelers", "Gen
109135
results = []
110136
for index, row in df_n_vax.iterrows():
111137
n_vax = row.values
112-
result = ngm.simulate(n, n_vax, K, p_severe, ve)
138+
result = ngm.simulate(n, n_vax, beta, p_severe, ve)
113139
results.append({
114140
"Core Doses": n_vax[0],
115141
"Re": result["Re"],

0 commit comments

Comments
 (0)