|
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 21 22:24:00 2020
One is mever too old to learn.
@author: NicholasTU
一个感染者在传染期内在易感人群中引起的新感染者的期望人数,为传染病的传播速率,
有人称之为基本增生速率(Basic reproduction rate, R0)。
2020年1月25日
Dr. Eric Feigl-Ding, at Harvard University’s School of Public Health,
修正R0系数5.47;
2019 12 08是起始日期;
"""
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei'] #显示中文标签
plt.rcParams['axes.unicode_minus'] = False
import math
#武汉肺炎预测模型
gamma=1/14
#恢复率,44人
bb=0.05741
#感染率
n=13*10000*10000
#全国总人口
inf=1
rec=0
sus=n
t=1
inff=[]
#存放感染人数
recc=[]
#恢复健康的人数
suss=[]
#易感人群
time=[]
#从第一个病例发作开始计算天数
inff.append(inf)
recc.append(rec)
suss.append(sus)
time.append(t)
while True:
t=t+1
if t<=48:
k=5.47#哈佛大学推荐值
if t>48:
k=1.35#第48天,封城显现隔离效果,K减小;
if t>200:
break
beta=k*bb#beta感染率
a=inf
b=rec
c=sus
rec=b+gamma*a
inf=a+beta*a*c/n-gamma*a
sus=n-rec-inf
inff.append(round(inf))
recc.append(rec)
suss.append(round(sus))
time.append(t)
for i in range(200):
print("第",time[i],"天全国累计的总感染人数=",n-suss[i])
#print(suss)
#print(inff)
#print(recc)
#plt.plot(time,suss,'b-',label='suspect')
plt.plot(time,inff,'r-',label='infect')
#plt.plot(time,recc,'g-',label='recover')
plt.xlabel('day')
plt.ylabel('population')
plt.xlim(0,201)
plt.title('武汉新型冠状病毒全国感染肺炎预测模型_2 by@NicholasTU')#
plt.legend(loc='upper right')
plt.show() |
|