<jupyter_start><jupyter_text>Parameter Initialization<jupyter_code># Total population, N.
N = 93000

# Initial number of infected and recovered individuals, I0_a and R0.
I0, R0, E0, D0 = 1, 0, 0, 0

# Everyone else, S0, is susceptible to infection initially.
S0 = N - I0 - R0 - E0 - D0

# Parameterss
beta = 0.3      # contact rate
gamma = 0.1 # mean recovery rate(gamma) (in 1/days)
sigma =  0.1  # incubation rate(sigma)
p_d = 0.05    #fatality rate

# A grid of time points (in days)
t = np.linspace(0, 300, 300)<jupyter_output><empty_output><jupyter_text>The SEIRD model differential equations<jupyter_code>def deriv(y, t, N, beta, gamma, sigma, p_d):
    S, E, I, R , D = y
    
    # Susceptible
    dSdt = -beta * S * I / N 
    
    # Exposed
    dEdt = beta * S * I / N - sigma*E 
    
    # Infected
    dIdt = sigma*E - gamma * I
    
    # Recovered
    dRdt = (1-p_d) * gamma * I
    
    # Diseased
    dDdt = p_d * gamma * I 
    
    return dSdt, dEdt, dIdt, dRdt, dDdt<jupyter_output><empty_output><jupyter_text>Integration<jupyter_code># Initial conditions vector
y0 = S0, E0, I0, R0, D0

# Integrate the SIERD equations over the time grid, t.
ret = odeint(deriv, y0, t, args=(N, beta, gamma, sigma, p_d))
S, E, I, R, D = ret.T<jupyter_output><empty_output><jupyter_text>Plotting<jupyter_code># Plot the data on five separate curves for S(t), E(t), I(t), R(t), D(t)
fig = plt.figure(facecolor='w',figsize=(10,10))
ax = fig.add_subplot(111, facecolor='#dddddd', axisbelow=True)
ax.plot(t, S/N, 'b', alpha=0.5, lw=2, label='Susceptible')
ax.plot(t, E/N, 'y', alpha=0.5, lw=2, label='Exposed')
ax.plot(t, I/N, 'r', alpha=0.5, lw=2, label='Infected')
ax.plot(t, R/N, 'g', alpha=0.5, lw=2, label='Recovered with immunity')
ax.plot(t, D/N, 'orange', alpha=0.5, lw=2, label='Diseased')

ax.set_xlabel('Time /days')
ax.set_ylabel('Number ('+str(N)+'s)')
ax.set_ylim(0,1.2)
ax.yaxis.set_tick_params(length=0)
ax.xaxis.set_tick_params(length=0)
ax.grid(b=True, which='major', c='w', lw=2, ls='-')
legend = ax.legend()
legend.get_frame().set_alpha(0.5)
for spine in ('top', 'right', 'bottom', 'left'):
    ax.spines[spine].set_visible(False)
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16948378254910917, 'fraction_numerical': 0.03471904979442668, 'mean_word_length': 4.011441647597254, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '161339', 'license': 'MIT', 'n_tokens_mistral': 991, 'n_tokens_neox': 934, 'n_words': 229, 'path': 'src/SIERD_model.ipynb', 'repo_name': 'GeoRouv/covid-compartmental-model', 'size': '2189'}