Skip to main content
Mathematics LibreTexts

32.2: Epidemic Dynamics - Continuous Model

  • Page ID
    69577
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    %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

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

    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) \nonumber \]

    Do This

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

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

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

    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)
    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; a detailed edit history is available upon request.

    • Was this article helpful?