Modeling and Simulation in Python: An Introduction for Scientists and Engineers by Allen B. Downey

Modeling and Simulation in Python: An Introduction for Scientists and Engineers by Allen B. Downey

Author:Allen B. Downey
Language: eng
Format: epub
Publisher: No Starch Press, Inc.
Published: 2023-04-15T00:00:00+00:00


decorate(xlabel='Contact rate (beta)',

ylabel='Fraction infected',

title='Sweep beta, multiple values of gamma')

Alternatively, we can plot each row like this:

for beta in [0.2, 0.5, 0.8, 1.1]:

label = f'beta = {beta}'

frame.loc[beta].plot(label=label)

decorate(xlabel='Recovery rate (gamma)',

ylabel='Fraction infected',

title='Sweep gamma, multiple values of beta')

This example demonstrates one use of a SweepFrame: we can run the analysis once, save the results, and then generate different visualizations.

Another way to visualize the results of a two-dimensional sweep is a contour plot, which shows the parameters on the axes and contour lines where the value of the metric is constant. The ModSim library provides contour, which takes a SweepFrame and uses Matplotlib to generate a contour plot:

contour(frame)



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.