0
使用简单的SIR模型。 我需要组织打印到终端的值,以我的老师可以轻松遵循的方式进行组织。 我被告知要查看numpy.zeros,但我是python的新手,我需要某人来帮助。如何使用numpy零来组织Python数组
import matplotlib.pyplot as plt
import numpy
beta = 0.24
gamma = 0.142857
Tstart = 0
Tend = 151
r = 0
s = (306.8 * 10**6)
i = (22 * 10**6)
def compute_next_day(t,R,I,S):
R[t] = gamma * I[t - 1] + R[t - 1]
I[t] = (beta * I[t-1] * S[t-1]/(r+i+s)) - gamma * I[t-1] + I[t-1]
S[t] = - (beta * I[t-1] * S[t-1]/(r+i+s)) + S[t-1]
print S[t-1], I[t-1], R[t-1]
def compute_entire_period(Tstart, Tend, R, I, S):
R[Tstart] = r
I[Tstart] = i
S[Tstart] = s
for t in range(Tstart + 1, Tend):
compute_next_day(t, R, I, S)
R = range(Tstart, Tend)
I = range(Tstart, Tend)
S = range(Tstart, Tend)
def graph(R, I, S):
plt.plot(R)
plt.plot(I)
plt.plot(S)
plt.ylabel("Population")
plt.xlabel("Time")
plt.show()
(compute_entire_period(Tstart, Tend, R, I, S))
(graph(R,I,S))
打印到终端的值是S,I,R值...
what currently appears on terminal want to organize like this
我觉得你的问题很不清楚。你到底想做什么? –
显示示例 - 您得到了什么以及您的期望。 – furas
添加了一些图片,所以你可以看到我要去的 –