Mathematical Models, Spring 2020
Course Content

Check back often for homework assignments, tutorials, and key topics covered each day.
This schedule is approximate and subject to change!

This is the webpage for the 10:45am–12:00 section.
Monday, January 27
In class:
Wednesday, January 29
Before class:
  • Make sure you have access to a copy of Python and the course content outside of class, by either installing it on your own machine or using Azure Notebooks on a campus machine. (Detailed instructions here)
  • Acquire a ≈80 page notebook to serve as your "Class Notebook".
    • Put your name and contact information on or near the cover of the notebook so you'll be able to get it back.
  • Thoroughly read all of the course webpage.
  • Complete the following two tasks:
    • Complete the First Day Survey, so I can learn about everyone's background and experience.
    • Take the Syllabus Quiz. Feel free to refer back to the course webpage to search for more in form. Retake the quiz as many times as necessary to earn a score of 100%. This will count toward your participation grade.
  • Fill out this Doodle to let me know when you are available for office hours this semester. (Pretend like it is a normal week with no holidays --- select the times when you would be able to come to office hours regularly.) I will try to choose times that work for most people.
  • Read Chapter 0, Section 1.0 (pages 1–3), and Sections 2.1–2.5 (pages 7–14) of Modeling and Simulation in Python. We will be starting with Chapter 2 in class Wednesday. It is OK if you do not understand everything. You are priming your brain for our in-class discussion. You may wish to write yourself some notes about questions that come up or concepts that you'd like to discuss in class.
  • Homework Questions: Complete the following homework questions in your class notebook and be prepared to discuss them in class. Work in your class notebook. Label the top of the page by the date and Homework #1.
  • Objects
    • 1-1. Write a sentence that explains what a State object is.
    Comprehension/Vocabulary (Requires some research in the text)
    • 1-2. In the introduction to Chapter 1, the author explains a quality of a model that might be desirable. Copy down the paragraph that starts "But often ".
    • 1-3. How do we read the variables inside a State object?
    Coding (Give your brain and hands some practice.)
    • 1-4. What is the process called that makes the functions defined in modsim.py available to Python? What is the line of code that accomplishes this?
    • 1-5. What is the name of the package that allows us to work with units in python? (See page xii.) What is the line of code that imports this package into our notebooks? (See the course software page.)
    • 1-6. Every time you create a new file that runs python code you need to put the file into a particular directory in your file structure. What directory is it? (See the course software page.)
In class:
Monday, February 3
Before class:
  • Go to our Discussion Board: 8:35 -OR- 10:45. and contribute to the Daily Question for February 3.
  • Read all of Chapter 2 of Modeling and Simulation in Python.
  • Homework Questions: Complete the following homework questions in your class notebook. Remember to label the homework assignment as Homework #2 at the top of the page.
  • Objects
    • 2-1. Write a sentence that explains what a TimeSeries object is. How does it compare to a State object, if at all?
    Syntax
    • 2-2. Write down the syntax for the flip command. (That it, determine the input(s) that flip expects, determine the output(s) that flip returns, and explain in a sentence or two how the output(s) are related to the input(s).)
    • 2-3. Write down the syntax for the range command.
    Comprehension/Vocabulary (Fill in the blanks)
    • 2-4. In a function definition, the first line ends with a(n) _______ and the _______ of the function has to be indented.
    • 2-5. Write a short paragraph that explains in your own words what the step(p1,p2) function is doing and why.
    Coding
    • 2-6. In your personal version of the Chapter 2 notebook, define the function bike_to_olin, and make sure that it works like you expect it to by running it multiple times. (In your class notebook copy the final, working version of your code.)
In class:
Wednesday, February 5
Before class:
  • Read through the description of Project 1. Determine who you will want to work with on your project, and think about how you are interested in generalizing the simple bikeshare model. If you are unable to find a group, let me know in class. Your project proposal will be due on Monday by email.
  • Read Sections 2.7–2.8 and 3.1–3.5 of Modeling and Simulation in Python.
  • Go to our Discussion Board: 8:35 -OR- 10:45 and contribute to the Daily Question for February 5.
  • Homework Questions: Complete the following homework questions in your notebook. It is highly suggested that you work with one or more classmates on this assignment!!!
  • Syntax
    • 3-1. Write down the syntax for a for loop.
    Comprehension/Vocabulary (Fill in the blanks)
    • 3-2. Starting with a simple model and making gradual improvements is called _______.
    • 3-3. When you call a function, the values you provide are called _______; inside the function, those values get assigned to the function's _______.
    • 3-4. In Python, True and False are _______, not to be confused with 'True' and 'False', which are _______.
    Analysis (Reflect and Write)
    • 3-5. What does the author consider to be one of the most useful tools for debugging? Write a sentence explaining why it would be a helpful tool.
    • 3-6. In a paragraph or two, compare and contrast arguments and parameters. In what ways are they similar? In what ways are they different?
    Coding (Make sure you work in your notebooks directory. You do not need to answer these questions in your class notebook. Instead, upload your answers using the link below.)
    • 3-7(a). Create a new Jupyter notebook that imports modsim (and also pint).
    • 3-7(b). In this new notebook, write code that creates a State object that contains two state variables, named heads and tails, assigns the value 0 to both, and assigns the State object to a variable named penny.
    • 3-7(c). Once you have evaulated that line of code, write an additional line of code that verifies that penny is defined correctly.
    • 3-8. In the Jupyter notebook from Question 3-7, write a for loop that calls flip() 10 times with 50% chance of both heads and tails. Use your State object penny to keep track of the number of heads and tails that have been flipped.
    • When you have completed Questions 3-7 and 3-8, upload your .ipynb file here. (If you are working in Azure Notebooks you will need to download your file first before uploading it here.) [If you work together in a group, each group member must submit their own file.]
In class:
  • Homework Discussion
  • Arguments vs. parameters
  • Metrics
  • Discussion of Project 1
  • Link to in-class modified Chapter 2 notebook: 8:35am - OR - 10:45am
  • Link to in-class coin flipping notebook: 8:35am - OR - 10:45am
Monday, February 10
Before class:
  • Read Sections 3.4–3.6 and Section 4.5 of Modeling and Simulation in Python.
  • Homework Questions: Complete the following homework questions in your class notebook. It is highly suggested that you work with one or more classmates on this assignment!

  • Comprehension/Vocabulary (Fill in the blanks)
    • 4-1. A _______ causes a function to end immediately without running any additional statements.
    • 4-2. == is a(n) _______, and should not be confused with =, which is a(n) _______.
    • 4-3. Write down the fundamental steps of incremental development.
    • 4-4. What is the difference between the the two functions bike_to_wellesley() and bike_to_wellesley(state)? Write a paragraph that gives one or more reasons why the first would be better than the second and one or more reasons why the second would be better than the first.
    • 4-5. Write down the definition of a metric. Write a sentence that explains what a metric is in your own words. Give an example of a metric that you interact with in daily life.
    Coding
    • Build upon our coin flipping Jupyter notebook from Questions 3-7 and 3-8.
    • 4-6. Copy the code from Question 3-8 into a new cell. Modify the code by adding in print commands that do the following. Each time flip() is called, it should print out whether the flip was a heads or a tail. When all the flips are done, it should print out the number of heads and tails that were seen. Check that your code also works when you increase the number of flips from 10 to something larger. In your class notebook, copy down this information for a couple of trials.
In class:
  • Homework Discussion
  • Constructing a Problem Statement
  • Introducing Parameters
  • Negative bikes
  • Functions that return values
  • Link to in-class modified Chapter 3 notebook: 8:35am - OR - 10:45am
There is no class on Wednesday, February 12 or Monday, February 17.
  • Work with your group to create a precise problem statement that you will investigate for Project 1. Each group should send Prof. Chris one email (per group) before noon on Wednesday, February 12 with (a) your group members, (b) the precise problem statement you will be investigating, and (c) some vague thoughts about what will need to be modified from the basic simulation to implement your changes. He will give feedback so you can revise if necessary.
Wednesday, February 19
Before class:
  • Read Chapter 4 of Modeling and Simulation in Python.
  • Go to our Discussion Board: 8:35 -OR- 10:45 and contribute to the daily question.
  • Homework Questions: Complete the following homework questions in your class notebook.
  • Objects
    • 5-1. Write a sentence that explains what a SweepSeries object is. How does it compare to a TimeSeries object, if at all?
    Syntax
    • 5-2.
      (a) Write down the syntax for the linspace command.
      (b) What array is generated by linspace(0,1,5)?
      (c) What array is generated by linspace(2,10,4)?
      (d) How would you use linspace to generate the array with numbers 0.0, 0.3, 0.6, 0.9, and 1.2?
    Coding
    • 5-3. Complete the exercises at the end of the Chapter 3 Jupyter notebook having to do with keeping track of the time until the first customer arrives and doesn't find a bike.
    • 5-4. Run the code from Question 5-3 multiple times, and at the bottom of the same Jupyter notebook create a text cell where you type out the values for "olin_empty", "wellesley_empty", and "t_first_empty" for five runs to get a feel for the type of data that appears. (To create a text cell (instead of a cell for python code), convert the cell to a Markdown cell using the menu.)
    • When you have completed Questions 5-3 and 5-4, upload your .ipynb file here.
    Analysis
    • 5-5. In a paragraph or two, Compare and contrast docstrings and comments. In what ways are they similar? In what ways are they different?
    • 5-6. In a paragraph or two, explain what it means to sweep a variable. Why would this be a useful thing to do?
In class:
  • Homework Discussion
  • Sweeping variables
  • Completion of the discussion of the bikeshare model.
  • Prof. Chris will walk around and talk with you about your project.
  • Link to in-class modified Chapter 3 notebook: 8:35am - OR - 10:45am
IMPORTANT: Start working on your simulation early. If you and your group are confused or have issues with the coding of the simulation, stop by during office hours Wednesday afternoon 2/19 (3:30-4:30+), Thursday morning 2/20 (10-11+), or schedule an appointment to talk with me.
Monday, February 24
Before class:
  • Work in your group to modify the bikeshare simulation to address your problem statement.
  • Go to our Discussion Board: 8:35 -OR- 10:45 and contribute to the daily question.
  • Prepare to turn in your notebook for collection today.
In class:
  • I will collect class notebooks.
  • Determining explicit assumptions
  • Assumptions vs. Expectations
  • Results
  • Prof. Chris will walk around and talk with you about your project.
Wednesday, February 26
Before class:
  • Complete your project.
  • Each group should bring in THREE paper copies of their writeup.
  • Each group should also have access to their python notebook for feedback.
In class:
  • Peer Review Day.
Monday, March 2
Before class:
  • Use Monday's peer feedback to revise your project for submission.
  • Please bring in a paper version of your writeup.
  • Turn in your final project here:
    • Upload your writeup here. Make sure its file name is of the form Names.docx or Names.pdf. (Replace "Names" by the first names of your group members, so it looks like p1-AliceChrisQiang.pdf) Only one submission per group is necessary.
    • Upload your code file here. (You may have to download it from Azure Notebooks first.) Make sure its file name is Names.ipynb and that it runs WITH NO ERRORS when all the cells are evaluated in order from top to bottom. Only one submission per group is necessary.
    • Upload your group dynamics paragraph here. Make sure its file name is p1-FirstName.txt or p1-FirstName.pdf or p1-FirstName.docx. Reminder: Everyone must submit a group dynamics paragraph, written independently.
  • Read through Chapter 5, Section 6.1, and Section 10.2 of Modeling and Simulation in Python.
  • Homework Questions:
  • Objects
    • 6-1. Write a sentence that explains what a System object is. How does it compare to a State object, if at all?
    • 6-2. Write a sentence that explains what a DataFrame object is. How does it compare to a TimeSeries object, if at all?
    Syntax
    • 6-3. What is the syntax of linrange? How does it compare to linspace, if at all?
  • We are going to be thinking about population growth. Spend a few minutes brainstorming a few examples of populations that change over time—we'll discuss in class.
In class:
Wednesday, March 4
Before class:
  • You will be receiving an email with information about logging into Gradesly. Practice logging in. If you are having trouble, let me know.
  • Read Chapters 6 and 7 of Modeling and Simulation in Python.
  • Homework Questions: Complete the following homework questions in your notebook. Feel free to work with others to complete these exercises!
  • Comprehension
    • 7-1. Write down the definition of proportional. It is not defined in the book; you'll need to do some outside research if you don't know this definition.
    • 7-2. Write a paragraph that explains what the author means when they talk about "factoring out the update function", the title of Section 6.3.
    • 7-3. What is happening in Figure 7.2 on page 54?
    Coding
    • 7-4. (a) Find any webpage that has a table of data that changes over time (b) use the tools we discussed from Chapter 5 to import this data into python with the time column as the index column. (c) Change the column headings to have short, simple names. (d) Choose one column to single out as a Series object, and plot the dataset.
    • Upload your Python notebook for Problem 7-4 here. At the top of your notebook in a text cell write a small paragraph about where the data comes from. If you ran into trouble, use this space to describe your troubles.
In class:
  • Constant growth model
  • Proportional growth model
  • Quadratic growth model
  • Link to notebook that runs all three population growth models: 8:35am - OR - 10:45am
Monday, March 9
Before class:
  • Read through the description of Project 2. Start to think about which of the options you are most interested in simulating.
  • In the "notebooks" folder where all your python notebooks are is a file named "rabbits.ipynb". Read through the notebook through the cell containing the code
    system = make_system()
    run_simulation(system)
    final_population(system)
    
    We will be discussing this in class.
  • Re-read Section 4.4 of our book to refresh ourselves about sweeping variables.
  • Homework Questions: Complete the following homework questions in your notebook. Feel free to work with others to complete these exercises!
  • Coding
    • 8-1. (parts a, b, c, and d) Read Section 7.3 of Modeling and Simulation in Python entitled "Dysfunctions". The examples from the text are coded in the Chapter 7 python notebook. Work through these examples in your python notebook and try to understand the issues surrounding each of the examples. In your class notebook, write a paragraph in your own words that explains what is happening in each example.
  • Link to notebook that runs all three population growth models: 8:35am - OR - 10:45am
  • Go to our Discussion Board: 8:35 -OR- 10:45 and contribute to the daily question.
In class:
  • Discussion of Daily Question
  • Programming the population model in python
  • The Rabbit Model
  • Sweeping variables.
  • Link to in-class modified rabbit notebook: 8:35am - OR - 10:45am
Wednesday, March 11
Before class:
In class:
  • Completing our discussion about the population model.
  • Explanatory vs. Predictive models
  • Prediction
  • Get into your group for Project 2 and determine a plan to meet virtually or in-person over the next week.
Transition to Online Learning
How we are holding our classes:
  • We will be holding our class at our regular class time using Google Meet.
  • To access our Google Meet session, follow one of these options:
    • Go to https://meet.google.com/ffg-bzbw-kfv.
    • Download the Google Meet App onto your device and connect using the meeting code ffg-bzbw-kfv
    • You can also join by phone: Call ‪+1 574-316-3591‬ and enter PIN: ‪251 098 718‬#
  • When you join the room, please mute your microphone.
  • I will be asking you to reply to certain prompts by typing in the chat box.
  • If you want me to repeat or clarify something, please type in "Repeat" or "Clarify".
  • If you have a question or would like to speak during the session, you can type it in or simply type in "Q" or "?".
  • I may ask you to unmute yourself to communicate by voice.
  • I will record our discussions and post them in our Google Group.
Online Classes Start
Monday, March 23
Before class:
  • Refresh your memory about Homework #8-1. Were any of the dysfunctions confusing to you? If so, let me know at the start of Monday's class and I will discuss them.
  • Read through this modified rabbits notebook through the cell containing the code
    system = make_system()
    run_simulation(system)
    final_population(system)
    
    and answer the following question:
    • 10-1. Find the assumptions underlying this model. What type of growth is being simulated? Is it a reasonable assumption?
In class:
  • Dysfunctions
  • The Rabbit Model
  • Explanatory vs. Prediction Models
  • Questions on the Population Model
  • Link to in class Chapter 7 notebook: Chapter 7 notebook
  • Link to in-class modified notebook: rabbits
Wednesday, March 25
Before class:
  • Re-read Section 4.4 of our book to refresh yourself about sweeping variables.
  • In the modified rabbits notebook, read through the two sections named "Sweep the Birth Rate" and the "Sweep the Death Rate"
    • 10-2. Think about the charts in rabbits.ipynb in the "Sweep the Birth Rate" and the "Sweep the Death Rate" sections. What are they saying?
In class:
  • Sweeping variables.
  • The Rabbit Model
  • Link to in-class modified notebook: rabbits
Online Classes Pause: New Schedule
No classes on Monday March 30 or Wednesday April 1.

BUT: There is class on Monday, April 6 and on TUESDAY, April 7.
 
THEN: Classes will be Mondays and Wednesdays through the rest of the semester, starting April 13. (Which is no longer part of Spring Break.)
Office Hours:
I will hold office hours on Google Meet from 10-noon on Thursday, March 26 and 10-noon on Thursday, April 2. Please join to ask math questions but also if you just want to talk to another friendly face.
 
To access office hours, follow one of these options:
  • Go to https://meet.google.com/fyg-udfp-gtw.
  • Download the Google Meet App onto your device and connect using the meeting code fyg-udfp-gtw
  • You can also join by phone: Call ‪+1 252-377-1173 and enter‬ PIN: ‪624 348 575‬#
Online Classes Resume
Monday, April 6
Before class:
  • Read Chapter 11 of Modeling and Simulation in Python.
  • Homework Questions: Complete the following homework questions in your class notebook.
  • Objects
    • 11-1. What is a TimeFrame object? How does it compare to a TimeSeries object or a DataFrame object, if at all?
    Comprehension/Vocabulary (Fill in the blanks)
    • 11-2. An SIR model is an example of a _______ model.
    • 11-3. Getting vaccinated is not just good for you; it is also good for the people you might otherwise infect. What is this phenomenon called?
In class:
  • Homework Discussion
  • Implementation of SIR model in Python
  • Metrics of interest
  • Sweeping a parameter
  • Link to in-class notebook: Chapter 11
Tuesday, April 7
Before class:
  • Read Section 11.8 and read Chapter 12 of Modeling and Simulation in Python.
  • Homework Questions: Complete the following homework questions in your class notebook.
  • Comprehension/Vocabulary (Fill in the blanks)
    • 12-1. For what real-world reasons might we like to know the largest value of (one or more of) S, I, or R and when it might happen?
    • 12-2. In our model, we will model vaccination as moving people directly from the Susceptible state to the Recovered state. Why is this a reasonable thing to do?
    • 12-3. What does the book say that "hand washing" does to the model? And why should that be the case?
    Syntax
    • 12-4. Suppose frame is a TimeFrame object with columns labeled 'A', 'B', 'C', and 'D'.
      • What do you type to access frame's first column?
      • What do you type to access frame's first row of data?
      • What do you type to plot all the data in frame?
    • 12-5. If S is a TimeSeries object, What is the difference between S.max and S.idxmax?
In class:
  • Homework Discussion
  • Implementing the TimeFrame
  • Programming Interventions
  • Sweeping Interventions
  • Link to in-class notebook: Chapter 11
  • Link to in-class notebook: Chapter 12
Monday, April 13
Before class:
  • Go to our Discussion Board and contribute to the daily question.
  • Homework Questions: Complete the following homework questions in your class notebook.
  • Comprehension/Vocabulary
    • 13-1. If you change the time between contacts, how should that impact how many people will be infected and the dynamics of the number of people infected over time? Similarly, if you change the recovery time, how should that impact how many people will be infected and the dynamics of the number of people infected over time?
    Coding
    • 13-2. Modify the tc and tr numbers in the Chapter 11 Python Notebook, re-run the simulation, and determine how many people are infected as those numbers change. See if the final result matches the expectations you gave in your answer to Question 13-1.
    • 13-3. There are three metrics given in the Exercise in the Metric section of the Chapter 12 python notebook. Create functions that implement each of these three metrics, just as we have created a calc_total_infected function that computes the metric of the number of total people who were infected during the simulation by taking as an input the TimeFrame named results.
In class:
  • Discussion of First Project Grading
  • Intervention: Immunizations
  • Link to in-class notebook: Chapter 12
  • Link to in-class notebook: Chapter 13
Wednesday, April 15
Before class:
  • Join Discord. (See below.)
  • Work on Final Project Brainstorming Worksheet
In class:
  • Intervention: Hand Washing
  • Transitioning over to Discord
  • Final Project Brainstorming
Joining Discord:
Step 1: Use the following invite link for a shortcut to the Discord Server.
  • 8:35 class: https://discord.gg/DH4FUQz
  • 10:45 class: https://discord.gg/YTn29zH
Step 2: Log in or create an account:
If you already have a Discord account, log in - under the "Continue button" there is a link to log in with your existing account information.

If you don't have a Discord account, you're going to create one:
  • Type in the username that you will want to use on Discord. (This has to be relatively unique in the system so they might say you have to choose a different name.)
  • You may have to verify that you are not a robot.
  • It asks you to claim your account. Enter your email address and a password to create your account.
Step 3: Join our room and let us know who you are.
On the right panel your username appears to let people know who is in the discussion room. Right click your username and select "Change Nickname". Type in your actual name and this will update the room with your real name.

If you're having trouble with this step, just type in your real name at the bottom of the screen and I'm able to change your user name to your real name for you.
Step 4: Add me as your friend.
You've joined our Discord Server and now we're going to set up our group chat rooms where we can do video chats with each other.
  • 4A: On the upper left hand side of the screen is the little joystick icon - click on it to go to your message list.
  • 4B: Add "chanusa#9967" as a friend. If this is your first time with an account, this should be the only option. Type in chanusa#9967 and click "Send Friend Request".
  • 4C: I will accept your friend request and create a group chat with the people in each project group. (In order for me to do this, I need to be online and each group member has to join discord.) This group chat will appear in the list of "Direct Messages" on this screen.
Monday, April 20
Before class:
  • Finalize your project statement for the final project.
  • Complete your Final Project Brainstorming Worksheet
  • Collect relevant data for your project.
In class:
  • In-class work day. Check in with Prof. Hanusa during allocated time.
Wednesday, April 22
Before class:
  • Start programming your project simulation.
In class:
  • In-class work day. Check in with Prof. Hanusa during allocated time.
Monday, April 27
Before class:
In class:
  • In-class work day. Check in with Prof. Hanusa during allocated time.
Wednesday, April 29
Before class:
  • Continue your project work. You must have translated your population dynamics model into Python and run the simulation.
In class:
Monday, May 4
Before class:
  • Complete your work on your project's simulation.
  • Do a parameter sweep for a parameter of your choosing.
  • Interpret your results as real-world answers to your problem statements.
In class:
  • In-class work on your project.
  • Focus on model assumptions, methodology, and errors.
Wednesday, May 6
Before class:
  • Make a large amount of progress on your project. You should be nearing completion.
In class:
  • In-class work day. Ask Prof. Hanusa last minute questions about the project.
Before you go to bed on Thursday, May 7
Monday, May 11
Before class:
In class:
  • Meet in Discord to discuss the project with the other group.
  • After the discussion, work with your groupmates to improve your project. Also start working on your presentation.
Wednesday, May 13
Before class:
In class:
  • Work on the presentation, both the slides and what you are going to say. Make sure you will be able to address all the criteria on which the presentation will be graded.
Monday, May 18
Before class:
  • Revise your project and prepare to present your work in class.
  • Think to spend time doing a presentation peer review with another group in class. At the very least go through this checklist on your own.
  • Turn in your final project here:
    • Upload your presentation slides here. Make sure its file name is of the form p3-Names.pdf or p3-Names.pptx. (Replace "Names" by the first names of your group members, so it looks like p3-AliceChrisQiang.pdf)
    • Upload your writeup here. Make sure its file name is p3-Names.docx or p3-Names.pdf.
    • Upload your python notebook here. Make sure its file name is p3-Names.ipynb and that it runs WITH NO ERRORS when all the cells are evaluated in order from top to bottom.
    • Upload your group dynamics paragraph here. Make sure its file name is p3-FirstName.txt or p3-FirstName.pdf or p3-FirstName.docx. Reminder: There should be one of these from each person, written independently.
  • If you didn't do it yet, don't forget to turn in your homework by uploading a PDF or photos of your homework.
In class:
  • Project Presentations.
  • We will meet on Google Meet. One group member will present their slides and all group members will discuss their project. Make sure you have practiced multiple times!