Last active
March 15, 2020 17:54
-
-
Save skoba/abc760104be559881ab7269372bb03ea to your computer and use it in GitHub Desktop.
COVID-19 simuation by SEIR model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The preprints is available from https://www.preprints.org/manuscript/202002.0179/v1 | |
# S Susceptible | |
# E Exposed | |
# I Infected | |
# R Recovery | |
%matplotlib inline | |
import numpy as np | |
import matplotlib.pyplot as plt | |
r0 = 3. # basic reproduction number | |
p = 10. # Infectious period(day) | |
prevalence = 0.7 # patients/at-risk people | |
recovery = 1.0 # recovery rate from disease | |
initial_infection = 10. # initial number of carrier | |
beta = r0/p # propergation rate of infection | |
delta = prevalence/p # | |
nu = recovery/p # | |
N = 1000 # Population | |
D = 100 # observation days | |
t = np.arange(0, D, 1) | |
Ss = np.array([N]) | |
Es = np.array([0]) | |
Is = np.array([initial_infection]) | |
Rs = np.array([0]) | |
def dsdt(S, I): | |
return -beta * S * I / N | |
def dedt(S, I, E): | |
return beta * S * I / N - delta * E | |
def didt(E, I): | |
return delta * E - nu * I | |
def drdt(I): | |
return nu * I | |
for i in t[0:D-1]: | |
Ss = np.append(Ss, Ss[i] + dsdt(Ss[i], Is[i])) | |
Es = np.append(Es, Es[i] + dedt(Ss[i], Is[i], Es[i])) | |
Is = np.append(Is, Is[i] + didt(Es[i], Is[i])) | |
Rs = np.append(Rs, Rs[i] + drdt(Is[i])) | |
#print(Ss, Es, Is, Rs) | |
plt.plot(t, Ss, label='S') | |
plt.plot(t, Es, label='E') | |
plt.plot(t, Is, label='I') | |
plt.plot(t, Rs, label='R') | |
plt.legend() |
Author
skoba
commented
Feb 17, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment