Lesson 12 of 15
SIR Epidemic Model
SIR Epidemic Model
The SIR model divides a population into three compartments:
- S (Susceptible): can get infected
- I (Infected): currently infectious
- R (Recovered): immune
Equations
- : transmission rate (contacts per day probability of transmission)
- : recovery rate (1/days infectious)
- : total population (constant)
Key Metric: Basic Reproduction Number
- : epidemic grows (each infected person infects more than one)
- : epidemic dies out
COVID-19 had –. Measles has –.
Herd Immunity Threshold
An epidemic can't grow if enough people are immune. The threshold:
For : need immune.
Your Task
Implement sir(S0, I0, R0, beta, gamma, t_end, n) using Euler's method. Return (S, I, R) at time t_end.
Pyodide loading...
Loading...
Click "Run" to execute your code.