Skip to main content
Library homepage
 

Text Color

Text Size

 

Margin Size

 

Font Type

Enable Dyslexic Font
Mathematics LibreTexts

32.2: Epidemic Dynamics - Continuous Model

( \newcommand{\kernel}{\mathrm{null}\,}\)

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

%matplotlib inline
import matplotlib.pylab as plt
import numpy as np
import sympy as sym
sym.init_printing()
%matplotlib inline
import matplotlib.pylab as plt
import numpy as np
import sympy as sym
sym.init_printing()

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

For example, we have that

˙x1=dx1(t)dt=0.05x1(t)+0.04x2(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.

˙x2=dx2(t)dt=0.05x1(t)0.17x2(t)˙x3=dx3(t)dt=0.1x2(t)˙x4=dx4(t)dt=0.03x2(t)

Do This

We can write it as system of ODEs as ˙x(t)=Bx(t). Write down the matrix B in numpy.matrix

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

# Put your answer to the above question here.
# Put your answer to the above question here.
Do This

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

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

x0 = np.matrix([[1],[0],[0],[0]])
n = 200
x_all = np.matrix(np.zeros((4,n)))

### Your code starts here ###

### Your code ends here ###
for i in range(4):
    plt.plot(x_all[i].T)
x0 = np.matrix([[1],[0],[0],[0]])
n = 200
x_all = np.matrix(np.zeros((4,n)))

### Your code starts here ###

### Your code ends here ###
for i in range(4):
    plt.plot(x_all[i].T)

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

D2, C2 = np.linalg.eig(B)
np.allclose(C2*np.diag(D2)*C2**(-1), B)
C = C2
D2, C2 = np.linalg.eig(B)
np.allclose(C2*np.diag(D2)*C2**(-1), B)
C = C2

This page titled 32.2: Epidemic Dynamics - Continuous Model is shared under a CC BY-NC 4.0 license and was authored, remixed, and/or curated by Dirk Colbry via source content that was edited to the style and standards of the LibreTexts platform.

Support Center

How can we help?