Question: Hi please help me fix my code. I get some errors. I want to print 3 separate graphs. One graph that prints the number of

Hi please help me fix my code. I get some errors. I want to print 3 separate graphs. One graph that prints the number of Susceptible individuals vs time, 2nd graph prints number of Infected individuals vs time, and 3rd graph prints number of Recovered individuals vs time.

import scipy.integrate import matplotlib.pyplot as plt import numpy as np

def f(t, y): gamma = .07 beta = .9 N = 10000 dsdt = -beta * y[0] * y[1] / N didt = beta * y[0] * y[1] / N - gamma * y[1] drdt = gamma * y[1] return [dsdt,didt,drdt]

t0 = 0 t_bound = 200 y0 = np.array([9000, 1000, 0]) sol = scipy.integrate.RK45(f, t0, y0, t_bound) t = [] y = [] while sol.status == "running": t.append(sol.t) y.append(sol.y) sol.step()

plt.plot(t,sol[:,0]) plt.plot(t,sol[:,1]) plt.plot(t,sol[:,2]) plt.legend(("Susceptible", "Infected", "Recovered")) plt.xlabel("time") plt.ylabel("cases") plt.show()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!