Fitting the Model Visually - MA
For this section, you’ll need to have Slide 4: Exponential Model for MA of Modeling Covid Spread (Desmos) open on your computer.
1 Try changing the value of k, then a, then b to find three promising exponential models, graphing each one and labeling your values on the grids below.
a = |
a = |
a = |
Fitting the Model Programmatically - MA
For this section, open your copy of the Covid Spread Starter File.
2 In the space below, define exponential
for one of the models you fit in Desmos.
fun exponential(x): (
a * num-expt(
b , (~1 * x))) +
k end
Two Notes on this function definition:
-
num-expt
is the function that we use for exponents. It takes in 2 numbers: the base and the power, in this case b and x. -
(~1 * x)
at first it may appear that x is being multiplied by negative 1, but it is actually being multiplied by~1
(literally the value "roughly 1"). This tells Pyret to round off the calculation, prioritizing speed over precision to get a result that is "roughly accurate". We’ve added this to the function definition so that you won’t have to wait for several minutes for Pyret to runfit-model
to get an answer for question 4.
3 Update the definition for exponential
in the Definitions Area and click "Run" to reload it.
Then use fit-model
to determine how closely exponential
fits the MA-table
and fill in the blanks below to interpret the model.
Hint: If you forgot the contract for fit-model
, look it up in the contracts pages!
According to this exponential model, on June 9, 2020day zero there were about a + k y-units in MA, for a total of about a + k. This number grew exponentially, increasing by a factor of Growth Factor: b or Growth Rate: (b - 1) × 100 % every day. The error in the model is described by an S-value of about Sunits, which is a(n) bad, ok, good model considering that y-units in this dataset range from lowest y-value to highest y-value.
4 Estimate how many positive cases there will be after X days by looking at graph with your eyes, then use your model to find the answer.
Using your… | Eyes | Model | Using your… | Eyes | Model | Using your… | Eyes | Model |
---|---|---|---|---|---|---|---|---|
50 days |
|
|
150 days |
|
|
250 days |
|
|
350 days |
|
|
450 days |
|
|
550 days |
|
|
★ Rewrite the model to make Pyret do these calculations with extreme precision. (Remove the part where it multiplies by ~1
.)
WARNING: Be sure to save your work first, as there’s a good chance this will lock up your browser and require force-quitting!
What changed?
Data scientists perform calculations to do things like send satellites to far-away planets, or analyze large populations of a billion or more.
You know that the pros of using ~1
involve speed. What are the potential downsides of using ~1
to speed up a calculation?
These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, 1738598, 2031479, and 1501927). Bootstrap by the Bootstrap Community is licensed under a Creative Commons 4.0 Unported License. This license does not grant permission to run training or professional development. Offering training or professional development with materials substantially derived from Bootstrap must be approved in writing by a Bootstrap Director. Permissions beyond the scope of this license, such as to run training, may be available by contacting contact@BootstrapWorld.org.