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))
値は
what currently appears on terminal want to organize like this
あなたの質問は非常に不明です。あなたは正確に何をしたいですか? –
例を表示する - あなたが得るものと期待するもの – furas
はいくつかの写真を追加したので、私は何をしようとしているのかを見ることができます –