laser.measles.mixing.gravity
laser.measles.mixing.gravity
laser.measles.mixing.gravity.GravityMixing(scenario=None, params=None)
Bases: BaseMixing
Gravity migration model.
Computes a spatial mixing matrix based on patch populations and distances:
.. math::
1 | |
The scenario argument is optional. When this mixer is attached to a model via
InfectionParams(mixer=...) the model automatically sets the scenario before
the mixing matrix is first computed (lazy initialisation). You only need to pass
scenario explicitly when using the mixer standalone (e.g. to inspect the
matrix before running a simulation).
Parameters
scenario : pl.DataFrame or None, optional
Patch data with id, lat, lon, pop, and mcv1 columns.
If None, must be set before the mixing matrix is accessed (happens
automatically when the mixer is attached to a model component).
params : GravityParams or None, optional
Gravity model parameters. Uses :class:GravityParams defaults if None.
Examples
Typical usage — let the model set the scenario automatically:
.. code-block:: python
1 2 3 4 5 6 7 | |
Standalone usage (inspect the matrix before running):
.. code-block:: python
1 2 | |
laser.measles.mixing.gravity.GravityParams
Bases: BaseModel
Parameters for the gravity migration model.
Formula
.. math:: M_{i,j} = k \cdot p_i^{a-1} \cdot p_j^b \cdot d_{i,j}^{-c}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
float
|
Population source scale parameter |
required |
b
|
float
|
Population target scale parameter |
required |
c
|
float
|
Distance exponent |
required |
k
|
float
|
Scale parameter |
required |