COVID-19 Stochastic SIR¶
A simple stochastic SIR model for COVID-19
CovidSirStochasticModel(input)
¶
Bases: Model
A simple stochastic SIR compartmental model for COVID-19.
Uses tau-leaping: at each timestep the number of infection and recovery events is drawn from a Poisson distribution whose mean equals the deterministic rate. This gives demographic stochasticity while keeping the same expected trajectory as the ODE model.
Sets STOCHASTIC = True so the SimulationManager uses fixed-step Euler integration instead of the adaptive ODE solver.
Initialize the model and seed its PRNG for stochastic draws.
Falls back to beta = 0.4 and a 7-day recovery period when the config
omits them. A seed in the config gives reproducible trajectories;
otherwise the PRNG is seeded from system entropy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input
|
dict
|
Validated simulation configuration providing
|
required |
Source code in compartment/models/test_covid_sir_stochastic/model.py
define_parameters(schema)
classmethod
¶
Declare the stochastic SIR compartments, edges, and parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
ParameterSchemaBuilder
|
Schema builder to populate with
model info, the S/I/R compartments, the |
required |
Source code in compartment/models/test_covid_sir_stochastic/model.py
prepare_initial_state()
¶
Return the initial compartment populations for the solver.
Returns:
| Type | Description |
|---|---|
ndarray
|
Population matrix (compartments x admin zones) used as the solver's initial state. |
Source code in compartment/models/test_covid_sir_stochastic/model.py
equation(y, t, p)
¶
Tau-leaping stochastic SIR step.
Returns the per-step change (delta); the Euler integrator applies
y_{t+1} = y_t + dt * equation(...). Infection and recovery counts are
Poisson draws around the deterministic rates, clamped so no more
individuals move than exist.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y
|
ndarray
|
Current compartment values, ordered by
|
required |
t
|
float
|
Current time in days since the simulation start date. |
required |
p
|
tuple
|
Packed parameter tuple, unpacked via |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Stacked per-compartment deltas for this step. |