Mathematical Models, Spring 2019
Course Content
This page is for a past course. Find your current course here.
 

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

Monday, January 28
In class:
  • Welcome!
  • Introduction & Syllabus Discussion '
  • Sections 1.0 and 2.1 of Modeling and Simulation in Python.
  • What is Mathematical Modeling?
  • Steps of the Modeling Process
  • Course Philosophy
  • Meet the model(er)s
  • Visit the course webpage.
  • Getting started with a Jupyter Notebook. (Instructions here)
  • Go to Google Classroom and answer the Daily Question.
    • Here is how to log on: Visit Google Drive (on Google Apps for Education). Enter your QC Email Address. This will take you to a QC login page. Log in with your CAMS information.
    • Then go to Google Classroom.
    • Click on the + in the upper right corner to add a new class using course code bex47bg.
    • Click on the assignment labeled "Daily Question: January 28" and respond.
  • Randomness and flipping coins in Python
  • flip(): Adding in Randomness
  • Link to in-class modified notebook: Coin Flip Notebook
Wednesday, January 30
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 ≈100 page notebook to serve as your "Homework Notebook".
    • Put your name and contact information in the notebook so you'll be able to get it back.
    • Set aside the first five pages of the notebook. Label this section "Objects" for building a list of objects that we'll be using in this class.
    • Set aside the next five pages of the notebook. Label this section "Syntax" for building a list of functions that we'll be using in this class.
    • Answers to all other homework questions go afterward.
  • Thoroughly read all of the course webpage.
  • Go to Google Classroom. (Reminder: You must be logged in through your QC account and NOT be on your personal Gmail account!) 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. 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 homework notebook (working after the objects and syntax sections) and be prepared to discuss them in class. Work in your homework notebook.
  • Objects (Add to your Objects section.)
    • 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.)
In class:
Monday, February 4
Before class:
  • Meet for one hour outside of class with at least one other classmate. Your goal is to get together to talk about the class so far and compare answers to the homework questions below. You should also make sure you are able to use Python and Jupyter notebooks outside of class.
  • Prepare a piece of paper to bring to class on 2/4 and turn in. At the top of the page, write your name and write down the name(s) of the classmate(s) you met with and when you met. Below that, write one paragraph reflecting about something that you learned or experienced that you would not have if you had worked alone. Bring your paragraph to class; I will collect them, check them off, and they will count toward your homework grade.
  • Go to Google Classroom and contribute to the Daily Question for February 4.
  • Read all of Chapter 2 of Modeling and Simulation in Python.
  • Homework Questions: Complete the following homework questions in your homework notebook.
  • Objects (Add to your Objects section.)
    • 2-1. Write a sentence that explains what a TimeSeries object is. How does it compare to a State object, if at all?
    Syntax (Add to your Syntax section.)
    • 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. When you call a function, the values you provide are called _______; inside the function, those values get assigned to the function's _______.
    • 2-6. In Python, True and False are _______, not to be confused with 'True' and 'False', which are _______.
    Analysis (Reflect and Write)
    • 2-7. 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.
    Coding (Make sure you work in your code directory.)
    • 2-8(a). Create a new Jupyter notebook that imports modsim (and also pint).
    • 2-8(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.
    • 2-8(c). Once you have evaulated that line of code, write an additional line of code that verifies that penny is defined correctly.
In class:
Wednesday, February 6
Before class:
  • Read Sections 2.7–2.8 and 3.1–3.5 3 of Modeling and Simulation in Python.
  • Go to Google Classroom and contribute to the Daily Question for February 6.
  • Homework Questions: Complete the following homework questions in your homework notebook. It is highly suggested that you work with one or more classmates on this assignment!!!
  • Syntax (Add to your Syntax section.)
    • 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 _______.
    Coding
    • 3-3. In the Jupyter notebook from Question 2-8 above, 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.
    • 3-4. Copy the code from the previous question into a new cell. Modify the code by adding in print statements 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.
    Analysis
    • 3-5. In a paragraph or two, compare and contrast arguments and parameters. In what ways are they similar? In what ways are they different?
    • 3-6. In a paragraph or two, Compare and contrast docstrings and comments. In what ways are they similar? In what ways are they different?
In class:
  • Homework Discussion
  • For loops
  • TimeSeries
  • Plotting
  • Link to in-class modified notebook: Chapter 3
Monday, February 11
Before class:
  • Read through the description of Mini-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. Your project proposal will be due Wednesday.
  • Read Sections 3.4–3.6 and 4.5 of Modeling and Simulation in Python.
  • Do some exploration of the documentation from pyplot's plot function. See https://matplotlib.org/api/_as_gen/matplotlib.pyplot.plot.html or https://matplotlib.org/users/pyplot_tutorial.html or https://matplotlib.org/2.0.2/examples/index.html. Look to see how you can modify the style of plots in an interesting way. Try it out on some of the plots we've seen so far and share with us the most interesting modification you were able to make as the answer to today's Daily Question on Google Classroom.
  • Homework Questions: Complete the following homework questions in your homework 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 _______, and should not be confused with =, which is a(n) _______.
    • 4-3. Write down the fundamental steps of incremental development.
    Coding
    • 4-4. Build upon our coin flipping Jupyter notebook from earlier homework assignments. Create a new function called flip_count that takes n and p as parameters, where n is the number of times to flip and p is the probability of coin flip falling heads. It should output the number of heads and tails that are seen. Run the function a couple of times with different parameters to make sure it works how you would expect.
In class:
  • Homework Discussion
  • Introducing Parameters
  • Negative bikes
  • Metrics
  • Functions that return values
  • Discussion of Mini-Project 1
  • Constructing a Problem Statement
  • Link to in-class modified notebook: Coin Flip Notebook
  • Link to in-class modified notebook: Chapter 3
Wednesday, February 13
Before class:
  • Work with your group to create a precise problem statement that you will investigate for Mini-Project 1. Each group should send Prof. Chris one email before 9am on February 13 with (a) your group members and (b) the precise problem statement you will be investigating.
  • Read Chapter 4 of Modeling and Simulation in Python.
  • Contribute to today's Daily Question on Google Classroom.
  • Homework Questions: Complete the following homework questions in your homework 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?
      (e) How would you use linspace to generate the array with numbers 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, and 0.7?
    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. Write down a few of the answers you receive for "olin_empty", "wellesley_empty", and "t_first_empty".
    Analysis
    • 5-4. 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.
  • Determining Explicit Assumptions
  • Prof. Chris will walk around and talk with you about your project.
  • Link to in-class modified notebook: Chapter 4
No class on Monday, February 18
Start working on your simulation early. If you and your group are having issues with the coding of the simulation, stop by during office hours Tuesday or schedule an appointment to talk with me.
Wednesday, February 20
Before class:
  • Work in your group to modify the bikeshare simulation to address your problem statement.
  • Contribute to today's Daily Question on Google Classroom with any further questions about the bikeshare model.
  • Prepare your homework notebook to be turned in today.
In class:
  • I will collect homework notebooks.
  • Assumptions vs. Expectations
  • Results
  • Prof. Chris will walk around and talk with you about your project.
Monday, February 25
Before class:
  • Complete your project.
  • Each group should bring in THREE paper copies of their writeup.
  • Each group should have access to their python notebook for feedback too.
In class:
  • Peer Review Day.
Wednesday, February 27
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 p1-Names.pdf or p1-Names.pptx. (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 p1-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: There should be one of these from each person, written independently.
  • Read through Chapter 5, Section 6.1, and Section 10.2 of Modeling and Simulation in Python.
  • Homework Questions: Complete the following homework questions in your homework notebook.
  • 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. Contribute to today's Daily Question on Google Classroom with suggestions of populations that change over time.
In class:
No School Monday, March 4 — Snow Day!
Wednesday, March 6
Before class:
  • Read Chapters 6 and 7 of Modeling and Simulation in Python.
  • Homework Questions: Complete the following homework questions in your homework notebook.
  • Comprehension
    • 7-1. 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-2. What is happening in Figure 7.2 on page 54?
    Coding
    • 7-3. (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.
    • 7-4. 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 the examples and try to understand the issues surrounding each of the examples. In your homework notebook, write a paragraph in your own words that explains what is happening in each example. Contribute to today's Daily Question on Google Classroom with a question about what is happening, or a confusion you are having, or one that you figured out! If everything was clear to you, then help out your fellow classmates with an answer.
In class:
Monday, March 11
Before class:
  • Revise your Project 1.
  • Please bring in a paper version of your writeup.
  • Turn in the revised project here:
  • Contribute to today's Daily Question on Google Classroom by sharing two populations that have growth functions that are not the same type and justify your reasoning.
  • Upload your Python notebook from Homework Question 7-3 by 9am on 3/11. 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:
  • Coding our population model.
  • Link to in-class modified notebook: Chapter 7
Wednesday, March 13
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 code folder where all the 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.
  • If you don't remember when we discussed sweeping variables in class, re-read Section 4.4 of our book.
  • Contribute to today's Daily Question on Google Classroom by asking a question about the population model. If you also share a similar concern to a classmate, let them know, and if you are able to answer any questions, please share your knowledge.
In class:
  • Discussion of Daily Question
  • The Rabbit Model
  • Sweeping variables.
  • Link to in-class modified notebook: Rabbit Model
  • Discussion of the Project Deliverables
Monday, March 18
Before class:
  • Decide who you want to work with on your project and decide which of the project options you are most interested in pursuing. Start collecting data for your populations of interest. Bring these ideas to the brainstorming session in class this day.
In class:
  • Explanatory vs. Predictive
  • Work on the Brainstorming and Planning worksheet
  • Prof. Chris will walk around and talk with you about your project and your worksheet.
Wednesday, March 20
Before class:
  • Read Chapter 8 of Modeling and Simulation in Python.
  • Complete the Brainstorming and Planning worksheet and bring it to class.
  • Hone the primary question you and your group wish to investigate and have it ready for class this day. Bring in your strategy for modeling the growth of your population(s). Think about the growth function(s) assumptions underlying your simulation. Make progress on importing the data you want to analyze into a Python notebook.
In class:
  • Model Assumptions & Methodology
  • Differential Equations
  • After that we will have an in-class project work day. We will make sure everyone has their data in Python and has a plan for their underlying growth model and update function.
Monday, March 25
Before class:
  • Continue your project work. By this date, you must have translated your population dynamics model into Python and run the simulation. You should have decided upon a secondary question and that you will answer by determining a metric and sweeping a parameter.
In class:
  • In what ways can a model be good? Download notes here '
  • In-class work day. Prof. Chris will walk around and talk with you about your project.
Wednesday, March 27
Before class:
  • Continue work on your project.
  • Your python project results (population simulation and variable sweep) should be complete by today, leaving time for your group to work on the analysis and complete the quad chart by Monday.
In class:
  • In-class work day. Prof. Chris will walk around and talk with you about your project.
Monday, April 1
Before class:
  • Continue work on your project.
In class:
Wednesday, April 3
Before class:
  • Bring the final version of your Quad Chart to class. (Have your digital slides available to put on your table's screen and bring a print-out of the four slides too.) Prepare for your presentation as if you were presenting to the whole class. We will be doing a peer review.
In class:
  • Peer Review of Project 2
  • Determination of the Presentation Order.
Monday, April 8
Before class:
  • Revise your project and prepare to present your work in class.
  • Bring in your final Quad Chart (in poster format), your completed "Brainstorming and Planning" worksheet, and the Peer Review worksheets to class.
  • Turn in your final project here:
    • Upload your project slides here. Make sure its file name is of the form p1-Names.pdf or p1-Names.pptx. (Replace "Names" by the first names of your group members, so it looks like p1-AliceChrisQiang.pdf)
    • Upload your code file here. Make sure its file name is p1-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 p1-FirstName.txt or p1-FirstName.pdf or p1-FirstName.docx. Reminder: There should be one of these from each person, written independently.
In class:
  • Project Presentations
Wednesday, April 10
Before class:
  • Read Chapter 11 and Sections 12.1 and 12.2 of Modeling and Simulation in Python.
  • Homework Questions: Complete the following homework questions in your homework notebook.
  • Objects (Add to your Objects section.)
    • 8-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)
    • 8-2. An SIR model is an example of a _______ model.
    • 8-3. 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?
    • 8-4. 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:
  • Programming the SIR model
  • Link to in-class notebook: Chapter 11
  • Link to in-class notebook: Chapter 12
Monday, April 15
Before class:
  • Read over the information about Project 3.
  • Complete the partner preferences survey posted on Google Classroom before noon on Sunday, April 14.
  • Re-read Chapter 11 from where we left off in class and read Chapter 12 of Modeling and Simulation in Python.
  • Contribute to today's Daily Question on Google Classroom by asking a question about the SIR model or its implementation.
  • Homework Questions: Complete the following homework questions in your homework notebook.
  • Syntax (Add to your Syntax section.)
    • 9-1. 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?
    • 9-2. If S is a TimeSeries object, What is the difference between S.max and S.idxmax?

    Comprehension/Vocabulary (Fill in the blanks)
    • 9-3. 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?
    • 9-4. What does the book say that "hand washing" does to the model? And why should that be the case?
    • 9-5. 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
    • 9-6. 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 9-5.
In class:
  • Homework Discussion
  • Implementation of SIR model in Python
  • Link to in-class notebook: Chapter 11
  • Link to in-class notebook: Chapter 12
Wednesday, April 17
Before class:
  • Meet with your partner from Project 3 and determine which of the general project types you will have as the basis for your project and what about that project type is interesting to you. This brainstorming worksheet may be helpful.
  • Read Chapter 17 of Modeling and Simulation in Python.
  • Skim the Wikipedia page about System Dynamics and look at the pictures on this webpage about Stocks and Flows.
  • Homework Questions: Complete the following homework questions in your homework notebook.

  • Comprehension/Vocabulary (Fill in the blanks)
    • 10-1. Severe hyperglycemia is the defining symptom of ______.
    • 10-2. In the glucose minimal model, the initial concentration of glucose is not really measurable so it is treated as a ______.
    • 10-3. What are the "populations" that change over time that are simulated in the glucose minimal model?
    • 10-4. What are the "populations" that change over time that are simulated in a product adoption model?
    Coding
    • 10-5. 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:
  • Homework Discussion
  • Pharmokinetics
  • Product adoption
  • Implementing these multi-state models in Python
  • Link to in-class notebook: Chapter 17
  • Link to in-class notebook: Product Adoption
Monday, April 29
Before class:
  • Work to come up with a project topic / proposal with your groupmate. Determine the precise question you want to answer for your project. One member of each group should email this question to Prof. Chris before 9am on Monday 11/26. It may be helpful to use the brainstorming worksheet as a guide.
  • Come up with your expectations about what your results will say about your problem statement.
  • Set up a skeleton python notebook with the basics of your simulation. In other words, make sure the simplest version of your model is working correctly before you start making any modifications related to your project statement.
  • Contribute to today's Daily Question on Google Classroom by suggesting modifications to your model's assumptions.
  • Prepare your homework notebook for collection on Monday, April 29.
  • Submit your code for Homework 10-5 here.
In class:
  • Introduction to errors in the modeling process
  • In-class work on your simulation.
  • Prof. Chris will come around to give feedback about your proposed project question.
Wednesday, May 1
Before class:
  • Continue your work on your project's simulation.
  • Do a parameter sweep for a parameter of your choosing.
In class:
  • In-class work on your project.
Monday, May 6
Before class:
  • Complete your work on your project's simulation.
  • 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.
Please fill out the college-wide course evaluations. This is different from any course evaluations that I request on Google Classroom. Thank you for your feedback!
Wednesday, May 8
Before class:
  • Continue work on your project and writeup.
  • Contribute to today's Daily Question on Google Classroom about your model's limitations.
In class:
  • In-class work on your project.
  • How to write an abstract
Monday, May 13
Before class:
  • Complete the writeup for your project. Bring TWO paper copies of your project to class.
  • Prepare for your presentation as if you were presenting to the whole class. Have your digital slides available to put on your table's screen.
  • Please make an effort to fill out the college-wide course evaluations. Thank you for your feedback!
In class:
  • Peer Review Day.
Wednesday, May 15
  • Incorporate the feedback from peer review day into your project. If you would like Prof. Chris to give you feedback on your writeup and presentation so far, send the draft by today at 1:00pm. I will reply with feedback about where you should focus your revision efforts by Friday, May 17.
  • For clarity: There's no class today.
Monday, May 20
Before class:
  • Revise your project and prepare to present your work in class.
  • 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 p1-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.
In class:
  • Project Presentations.
  • Your writeup, presentation slides, and python code are due before class on May 20.
  • Your group dynamics paragraph is due by the evening of May 20.