# 传染病动力学模型 SI => SIS => SIR => SEIR（python）

2 篇文章 0 订阅

### Parameter

# parameter
I = 1 # The Infected
S = N - I # Susceptible
E = 0 # Exposed
R = 0 # Recover
r = 10 # Number of people per infected person per day.
r2 = 10
B = 0.01 # Transmission probability
B2 = 0.01
Time = 350 # Day
v = 0.02 # Cure Rate
a = 0.1 # Conversion Rate


### SI

# SI Model
# dI / dt =  r * B * I * S / N
# dS / dt = - r * B * I * S / N
# I(n) = I(n - 1) + r * B * I(n - 1) * S(n - 1) / N
# S(n) = S(n - 1) - r * B * I(n - 1) * S(n - 1) / N

TimeOfVirus = [1]
s_SI = [S]
i_SI = [I]
for day in range(1, Time):
TimeOfVirus.append(day + 1)
s_SI.append(s_SI[day - 1] - r * B * i_SI[day - 1] * s_SI[day - 1] / N)
i_SI.append(i_SI[day - 1] + r * B * i_SI[day - 1] * s_SI[day - 1] / N)


### SIS

# SIS Model
# dI / dt =  r * B * I * S / N
# dS / dt = - r * B * I * S / N
# I(n) = I(n - 1) + r * B * I(n - 1) * S(n - 1) / N - v * I
# S(n) = S(n - 1) - r * B * I(n - 1) * S(n - 1) / N + v * I

TimeOfVirus = [1]
s_SIS = [S]
i_SIS = [I]
for day in range(1, Time):
TimeOfVirus.append(day + 1)
s_SIS.append(s_SIS[day - 1] - r * B * i_SIS[day - 1] * s_SIS[day - 1] / N + v * i_SIS[day - 1])
i_SIS.append(i_SIS[day - 1] + r * B * i_SIS[day - 1] * s_SIS[day - 1] / N - v * i_SIS[day - 1])


### SIR

# SIR Model
# dS / dt = - r * B * I * S / N
# dI / dt = r * B * I * S / N - v * I
# dR / dt = v * I
# S(n) = S(n - 1) - r * B * I(n - 1) * S(n - 1) / N
# I(n) = I(n - 1) + r * B * I(n - 1) * S(n - 1) / N - v * I
# R(n) = R(n -1) + v * I(n - 1)

TimeOfVirus = [1]
s = [S]
i = [I]
R = [0]

for day in range(1, Time):
TimeOfVirus.append(day + 1)
s.append(s[day - 1] - r * B * i[day - 1] * s[day - 1] / N)
i.append(i[day - 1] + r * B * i[day - 1] * s[day - 1] / N - v * i[day - 1])
R.append(R[day - 1] + v * i[day - 1])


### SEIR

# SEIR Model
# dS / dt = - r * B * I * S / N
# dE / dt = r * B * I * S / N - a * E
# dI / dt = a * E - v * I
# dR / dt = v * I
# S(n) = S(n - 1) - r * B * I(n - 1) * S(n - 1) / N
# E(n) = E(n - 1) + r * B * I(n -1) * S(n - 1) / N - a * E(n - 1)
# I(n) = I(n - 1) + a * E(n - 1) - v * I
# R(n) = R(n -1) + v * I(n - 1)

TimeOfVirus = [1]
ss = [S]
ee = [E]
ii = [I]
rr = [R]

for day in range(1, Time):
TimeOfVirus.append(day + 1)
ss.append(ss[day - 1] - r * B * ii[day - 1] * ss[day - 1] / N)
ee.append(ee[day - 1] + r * B * ii[day - 1] * ss[day - 1] / N - a * ee[day - 1])
ii.append(ii[day - 1] + a * ee[day - 1] - v * ii[day - 1])
rr.append(rr[day - 1] + v * ii[day - 1])


### New SEIR

# New SEIR Model
# dS / dt = - r * B * I * S / N - r2 * B2 * E * S / N
# dE / dt = r * B * I * S / N - a * E + r2 * B2 * E * S / N
# dI / dt = a * E - v * I
# dR / dt = v * I
# S(n) = S(n - 1) - r * B * I(n - 1) * S(n - 1) / N - r2 * B2 * E(n - 1) * S(n - 1) / N
# E(n) = E(n - 1) + r * B * I(n -1) * S(n - 1) / N - a * E(n - 1) + r2 * B2 * E(n - 1) * S(n - 1) / N
# I(n) = I(n - 1) + a * E(n - 1) - v * I
# R(n) = R(n -1) + v * I(n - 1)

TimeOfVirus = [1]
ss = [S]
ee = [E]
ii = [I]
rr = [R]

for day in range(1, Time):
if day >= 60:
r = 5
r2 = 5
TimeOfVirus.append(day + 1)
ss.append(ss[day - 1] - r * B * ii[day - 1] * ss[day - 1] / N - r2 * B2 * ee[day - 1] * ss[day - 1] / N)
ee.append(ee[day - 1] + r * B * ii[day - 1] * ss[day - 1] / N - a * ee[day - 1] + r2 * B2 * ee[day - 1] * ss[day - 1] / N)
ii.append(ii[day - 1] + a * ee[day - 1] - v * ii[day - 1])
rr.append(rr[day - 1] + v * ii[day - 1])


• 2
点赞
• 18
收藏
觉得还不错? 一键收藏
• 4
评论
12-26
02-11
07-19
05-15
05-31
12-20 315
12-17 296
02-05 1208

### “相关推荐”对你有帮助么？

• 非常没帮助
• 没帮助
• 一般
• 有帮助
• 非常有帮助

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、付费专栏及课程。