Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

27 - Final Exam Review

Python Basics

Be familiar with the different variable types and understand how to use them. See the Python Foundations page.

Functions and Objects

How would you sum every third number from 1007 to 2023 using python? Can you set that up as a function? Can you now set that function up as part of an object?

Solving Equations

How would you solve multiple coupled, non-linear equations in python? Can you set that up as a function? Can you now set that function up as part of an object?

ODEInt Review

Example of using ODEInt to solve a system of ODEs with SEIRD model (S: susceptible, E: exposed, I: infected, R: recovered, D: dead). The SEIRD model approximates the number of people infected with a contagious illness in a population. The model is expressed as a system of differential equations and is solved numerically.

(365, 5)
(5, 365)

We’ll transpose the solution with the .T operator so that we can plot the solution for each variable as a function of time.

<Figure size 640x480 with 1 Axes>

Doing the same integration of the SEIRD model in Excel using Euler’s method is given here: lectures/supportfiles/inclasseulerdisease.xlsx

Regression Review

Different methods of regression include:

  • Linear Regression

  • Polynomial Regression

  • Custom relationship using curve_fit or least_squares or minimize

Examples could include:

  • Fitting a line to a set of data

  • Fitting a polynomial to a set of data

  • Fitting a custom relationship to a set of data

<Figure size 640x480 with 1 Axes>
R2 = 0.987
MAPE = 5.10%
popt = [2.20596932e-04 2.00189102e+01]

Integration Review

  • Python quad

  • Trapezoid method

area of mymodel fit between 0 and 10 = 222.05

Interpolation Review

  • Linear

  • Cubic

array(17.00692328)

Many of the same things done above can be completed in Excel. Click this link to see an example of linear regression and integration with the trapezoid method: lectures/supportfiles/LinearRegIntegrateEx.xlsx