Two Simple Epidemic Models

4085 days ago by medlock

# Set up t as a symbolic variable var('t') # Plot the simple model simpleModelPlot = plot(2.5 * t^2 * exp(-0.01 * t), (t, 0, 1000), color = 'red') # Fitted parameters # Population size N = 18185 # Transmission rate beta = 0.101874320 # Recovery rate gamma = 0.00349633756 # Standard SIR model def ODE_RHS(t, Y): (S, I) = Y dS = - beta * S * I / N dI = beta * S * I / N - gamma * I return (dS, dI) # Initial conditions S0 = N - 1 I0 = 1 # Set up numerical solution of ODE solver = ode_solver(function = ODE_RHS, y_0 = (S0, I0), t_span = (0, tMax), algorithm = 'rk8pd') # Numerically solve solver.ode_solve(num_points = 1000) # Plot solution ODEPlot = plot(solver.interpolate_solution(i = 1), 0, tMax) # Show the two plots together show(simpleModelPlot + ODEPlot)