Link to this document's Jupyter Notebook

In order to successfully complete this assignment you need to participate both individually and in groups during class. If you attend class in-person then have one of the instructors check your notebook and sign you out before leaving class. If you are attending asynchronously, turn in your assignment using D2L no later than 11:59pm on the day of class. See links at the end of this document for access to the class timeline for your section.


In order to successfully complete this assignment you need to participate both individually and in groups during class. If you attend class in-person then have one of the instructors check your notebook and sign you out before leaving class. If you are attending asyncronously, turn in your assignment using D2L no later than 11:59pm on the day of class. See links at the end of this document for access to the class timeline for your section.

In-Class Assignment: Linear Dynamical Systems

Image with the words COVID-19 and a render image of the virus

Image from: https://www.dshs.state.tx.us/coronavirus/default.aspx

Agenda for today's class (80 minutes)

  1. (20 minutes) Epidemic Dynamics - Discrete Case
  2. (20 minutes) Epidemic Dynamics - Continuous Model
  3. (20 minutes) Population Dynamics

1. Epidemic Dynamics - Discrete Case

The dynamics of infection and the spread of an epidemic can be modeled as a linear dynamical system.

We count the fraction of the population in the following four groups:

We denote the fractions of these four groups in $x(t)$. For example $x(t)=(0.8,0.1,0.05,0.05)$ means that at day $t$, 80\% of the population are susceptible, 10% are infected, 5% are recovered and immuned, and 5% died.

We choose a simple model here. After each day,

Do this: If we start with $x(0) = (1, 0, 0, 0)$ for day 0. Use the for loop to find the distribution of the four groups after 50 days?

Do this: Write a program to apply the above transformation matrix for 200 iterations and plot the results.


1. Epidemic Dynamics - Continuous Model

Instead of using the discrete markov model, we can also use a continuous model with ordinary differential equations.

For example, we have that

$$\dot{x}_1 = {dx_1(t)\over dt} = -0.05x_1(t)+ 0.04 x_2(t)$$

It means that the changes in the susceptible group depends on susceptible and infected individuals. It increase because of the recovered people from infected ones and it decreases because of the infection.

Similarly, we have the equations for all three groups. $$\dot{x}_2 = {dx_2(t)\over dt} = 0.05x_1(t)-0.17 x_2(t) \\ \dot{x}_3 = {dx_3(t)\over dt}= 0.1 x_2(t) \\ \dot{x}_4 = {dx_4(t)\over dt} = 0.03 x_2(t)$$

Do this: We can write it as system of ODEs as $$\dot{x}(t) = Bx(t)$$ Write down the matrix $B$ in numpy.matrix

Do this: Plot all the distribution for 200 days. Then compare it with the discrete version.


3. Population Dynamics

In this section, we consider the distribution of pupulation at different ages. Let $x(t)$ be a 100-vector with $x_i(t)$ denoting the number of people with agent $i-1$.

The birth rate is given in the vector $b$, where $b_i$ is the average number of births per person with age $i-1$. $b_i=0$ for $i<13$ and $i>50$.

The death rate is given by the vector $d$, where $d_i$ is the portion of those aged $i-1$ who dies this year.

Then we can model the population with the dynamic systems. We consider the 0-year old first. It includes all newborn from all ages, so we have $$x_1(t+1) = b^\top x(t)$$ Then we consider all other ages for $i>1$. $$x_i(t+1) = (1-d_i)x_{i-1}(t)$$

Do this: Find the $100\times 100$ matrix A2 such that $$x(t+1)=Ax(t)$$

Do this: Plot the population distribution at year 2020.


Congratulations, we're done!

If you attend class in-person then have one of the instructors check your notebook and sign you out before leaving class. If you are attending asynchronously, turn in your assignment using D2L.

Course Resources:

Written by Dr. Dirk Colbry, Michigan State University Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.