CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
AllenDowney

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: AllenDowney/ModSimPy
Path: blob/master/chap13.py
Views: 531
1
from modsim import *
2
3
# import code from previous notebooks
4
5
from chap11 import make_system
6
from chap11 import update_func
7
from chap11 import run_simulation
8
from chap11 import plot_results
9
10
from chap12 import calc_total_infected
11
12
from modsim import *
13
14
def sweep_beta(beta_array, gamma):
15
sweep = SweepSeries()
16
for beta in beta_array:
17
system = make_system(beta, gamma)
18
results = run_simulation(system, update_func)
19
sweep[beta] = calc_total_infected(results, system)
20
return sweep
21
22
from modsim import *
23
24
def sweep_parameters(beta_array, gamma_array):
25
frame = SweepFrame(columns=gamma_array)
26
for gamma in gamma_array:
27
frame[gamma] = sweep_beta(beta_array, gamma)
28
return frame
29
30
31