相似文件
换一批
经管之家送您一份
应届毕业生专属福利!
求职就业群
感谢您参与论坛问题回答
经管之家送您两个论坛币!
+2 论坛币
2月5日凌晨更新了SEIRS模型。 2月1日凌晨,根据国家卫建委官网公布的数据实时计算的R0值徘徊在了3.09(Tg=8.4)和3.61附近!R0值第一次出现了下降!详见下图表。 实时更新2019-nCoV基本再生数(R0)值: 基本再生数(R0)的定义:在发病初期,当所有人均为易感者时,一个病人在其平均患病期内所传染的人数。 基于SEIR模型计算的R0值公式如下:
,
R0值Python实现代码如下:
- # 此处各参数(p、Tg_1、Tg_2)取值参考其他博客(见文章最后博客链接)
- def R0func(defi,susp,t):
- # defi是确诊人数;susp是疑似人数;t是疾病已爆发时间
-
- # p为疑似病例转化为确诊病例的概率
- p = 0.695
- # Tg_1和Tg_2为生成时间(generation period)
- Tg_1 = 8.4
- Tg_2 = 10.0
- # yt为实际预估感染人数
- yt = susp * p + defi
- # lamda为早期指数增长的增长率
- lamda = math.log(yt)/t
-
- R0_1 = 1 + lamda * Tg_1 + p * (1 - p) * pow(lamda * Tg_1,2)
- R0_2 = 1 + lamda * Tg_2 + p * (1 - p) * pow(lamda * Tg_2,2)
-
- return R0_1,R0_2
复制代码
今天是2020年1月27日。根据国家卫生健康委的数据,截至2020年1月26日24时,中国30个省(区、市)累积报告确诊病例2744例,重症病例461例,累计死亡病例80例,累计治愈出院51例,疑似病例5794例,累计追踪密切接触者32799人,当日解除医学观察583人,现有30453人正在接受医学观察。 随着1月23日武汉市宣布全面封城后,各地确诊病例不断出现,2020年的新年因为新型冠状病毒(2019-nCoV)的传播而黯然失色。 本文尝试使用经典传染病模型对2019-nCoV进行建模,预测未来疾病走势。因传染病模型研究属于传染病动力学研究方向,不是本人的工作范围,因此,本人只是将模型中的微分方程,用Python进行实现,想起到抛砖引玉的作用。
(具体各个模型的理论细节,请移步其他文章) 模型一:SI-Model
- import scipy.integrate as spi
- import numpy as np
- import matplotlib.pyplot as plt
- # N为人群总数
- N = 10000
- # β为传染率系数
- beta = 0.25
- # gamma为恢复率系数
- gamma = 0
- # I_0为感染者的初始人数
- I_0 = 1
- # S_0为易感者的初始人数
- S_0 = N - I_0
- # T为传播时间
- T = 150
- # INI为初始状态下的数组
- INI = (S_0,I_0)
- def funcSI(inivalue,_):
- Y = np.zeros(2)
- X = inivalue
- # 易感个体变化
- Y[0] = - (beta * X[0] * X[1]) / N + gamma * X[1]
- # 感染个体变化
- Y[1] = (beta * X[0] * X[1]) / N - gamma * X[1]
- return Y
- T_range = np.arange(0,T + 1)
- RES = spi.odeint(funcSI,INI,T_range)
- plt.plot(RES[:,0],color = 'darkblue',label = 'Susceptible',marker = '.')
- plt.plot(RES[:,1],color = 'red',label = 'Infection',marker = '.')
- plt.title('SI Model')
- plt.legend()
- plt.xlabel('Day')
- plt.ylabel('Number')
- plt.show()
复制代码
模型二:SIS-Model
- import scipy.integrate as spi
- import numpy as np
- import matplotlib.pyplot as plt
- # N为人群总数
- N = 10000
- # β为传染率系数
- beta = 0.25
- # gamma为恢复率系数
- gamma = 0.05
- # I_0为感染者的初始人数
- I_0 = 1
- # S_0为易感者的初始人数
- S_0 = N - I_0
- # T为传播时间
- T = 150
- # INI为初始状态下的数组
- INI = (S_0,I_0)
- def funcSIS(inivalue,_):
- Y = np.zeros(2)
- X = inivalue
- # 易感个体变化
- Y[0] = - (beta * X[0]) / N * X[1] + gamma * X[1]
- # 感染个体变化
- Y[1] = (beta * X[0] * X[1]) / N - gamma * X[1]
- return Y
- T_range = np.arange(0,T + 1)
- RES = spi.odeint(funcSIS,INI,T_range)
- plt.plot(RES[:,0],color = 'darkblue',label = 'Susceptible',marker = '.')
- plt.plot(RES[:,1],color = 'red',label = 'Infection',marker = '.')
- plt.title('SIS Model')
- plt.legend()
- plt.xlabel('Day')
- plt.ylabel('Number')
- plt.show()
复制代码
模型三:SIR-Model
- import scipy.integrate as spi
- import numpy as np
- import matplotlib.pyplot as plt
- # N为人群总数
- N = 10000
- # β为传染率系数
- beta = 0.25
- # gamma为恢复率系数
- gamma = 0.05
- # I_0为感染者的初始人数
- I_0 = 1
- # R_0为治愈者的初始人数
- R_0 = 0
- # S_0为易感者的初始人数
- S_0 = N - I_0 - R_0
- # T为传播时间
- T = 150
- # INI为初始状态下的数组
- INI = (S_0,I_0,R_0)
- def funcSIR(inivalue,_):
- Y = np.zeros(3)
- X = inivalue
- # 易感个体变化
- Y[0] = - (beta * X[0] * X[1]) / N
- # 感染个体变化
- Y[1] = (beta * X[0] * X[1]) / N - gamma * X[1]
- # 治愈个体变化
- Y[2] = gamma * X[1]
- return Y
- T_range = np.arange(0,T + 1)
- RES = spi.odeint(funcSIR,INI,T_range)
- plt.plot(RES[:,0],color = 'darkblue',label = 'Susceptible',marker = '.')
- plt.plot(RES[:,1],color = 'red',label = 'Infection',marker = '.')
- plt.plot(RES[:,2],color = 'green',label = 'Recovery',marker = '.')
- plt.title('SIR Model')
- plt.legend()
- plt.xlabel('Day')
- plt.ylabel('Number')
- plt.show()
复制代码
模型四:SIRS-Model
- import scipy.integrate as spi
- import numpy as np
- import matplotlib.pyplot as plt
- # N为人群总数
- N = 10000
- # β为传染率系数
- beta = 0.25
- # gamma为恢复率系数
- gamma = 0.05
- # Ts为抗体持续时间
- Ts = 7
- # I_0为感染者的初始人数
- I_0 = 1
- # R_0为治愈者的初始人数
- R_0 = 0
- # S_0为易感者的初始人数
- S_0 = N - I_0 - R_0
- # T为传播时间
- T = 150
- # INI为初始状态下的数组
- INI = (S_0,I_0,R_0)
- def funcSIRS(inivalue,_):
- Y = np.zeros(3)
- X = inivalue
- # 易感个体变化
- Y[0] = - (beta * X[0] * X[1]) / N + X[2] / Ts
- # 感染个体变化
- Y[1] = (beta * X[0] * X[1]) / N - gamma * X[1]
- # 治愈个体变化
- Y[2] = gamma * X[1] - X[2] / Ts
- return Y
- T_range = np.arange(0,T + 1)
- RES = spi.odeint(funcSIRS,INI,T_range)
- plt.plot(RES[:,0],color = 'darkblue',label = 'Susceptible',marker = '.')
- plt.plot(RES[:,1],color = 'red',label = 'Infection',marker = '.')
- plt.plot(RES[:,2],color = 'green',label = 'Recovery',marker = '.')
- plt.title('SIRS Model')
- plt.legend()
- plt.xlabel('Day')
- plt.ylabel('Number')
- plt.show()
复制代码
扫码加我 拉你入群
请注明:姓名-公司-职位
以便审核进群资格,未注明则拒绝
|