SIR
dissmodel.models.sysdyn.sir.SIR
Bases: Model
Deterministic SIR epidemiological model.
Tracks the spread of an infectious disease through three compartments: susceptible, infected, and recovered. At each step, new infections and recoveries are computed based on contact rate, transmission probability, and disease duration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
susceptible
|
int
|
Initial number of susceptible individuals, by default 9998. |
required |
infected
|
int
|
Initial number of infected individuals, by default 2. |
required |
recovered
|
int
|
Initial number of recovered individuals, by default 0. |
required |
duration
|
int
|
Average number of steps an individual remains infectious, by default 2. |
required |
contacts
|
int
|
Average number of contacts per individual per step, by default 6. |
required |
probability
|
float
|
Probability of transmission per contact with an infected individual, by default 0.25. |
required |
Notes
The @track_plot decorators register susceptible, infected,
and recovered for automatic live plotting. Any
:class:~dissmodel.visualization.Chart connected to the same environment
will plot these variables at every step without any extra configuration.
The force of infection at each step is computed as:
.. math::
\alpha = contacts \times probability
\Delta I = I \times \alpha \times \frac{S}{N}
\Delta R = \frac{I}{duration}
Examples:
>>> from dissmodel.core import Environment
>>> env = Environment(end_time=30)
>>> sir = SIR()
>>> env.run()
Source code in dissmodel/models/sysdyn/sir.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
execute()
Advance the model by one time step.
Computes new infections and recoveries, then updates the susceptible, infected, and recovered compartments.
Source code in dissmodel/models/sysdyn/sir.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
setup(susceptible=9998, infected=2, recovered=0, duration=2, contacts=6, probability=0.25)
Configure the model parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
susceptible
|
int
|
Initial number of susceptible individuals, by default 9998. |
9998
|
infected
|
int
|
Initial number of infected individuals, by default 2. |
2
|
recovered
|
int
|
Initial number of recovered individuals, by default 0. |
0
|
duration
|
int
|
Average number of steps an individual remains infectious, by default 2. |
2
|
contacts
|
int
|
Average number of contacts per individual per step, by default 6. |
6
|
probability
|
float
|
Probability of transmission per contact, by default 0.25. |
0.25
|
Source code in dissmodel/models/sysdyn/sir.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |