Skip to content

Instantly share code, notes, and snippets.

@sunprinceS
Created May 29, 2020 01:34
Show Gist options
  • Save sunprinceS/8af98e7d8f419bc9fbc4cf76f10cfe5a to your computer and use it in GitHub Desktop.
Save sunprinceS/8af98e7d8f419bc9fbc4cf76f10cfe5a to your computer and use it in GitHub Desktop.
GAMMA =1.0/10 # (1/D)
### Model ###
def sir_diff_eq(y, t, r0, gamma, N, t_y_interpolated):
S, I, R = y
def beta(t):
try:
return t_y_interpolated[int(t)] * r0 * gamma
except:
return t_y_interpolated[-1] * r0 * gamma
dSdt = -beta(t) * I * S / N
dIdt = beta(t) * I * S/N - gamma * I
dRdt = gamma * I
return dSdt, dIdt, dRdt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment