laser.measles.mixing.gravity
laser.measles.mixing.gravity
laser.measles.mixing.gravity.GravityMixing(scenario=None, params=None)
Bases: BaseMixing
Gravity migration model for spatial mixing.
Computes a spatial mixing matrix where travel probability between patches is proportional to population sizes and inversely proportional to distance:
The scenario is optional at construction time. When attached to a
model via InfectionParams(mixer=...), the model sets the scenario
automatically before the mixing matrix is first computed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario
|
DataFrame | None
|
Patch data with |
None
|
params
|
GravityParams | None
|
Gravity model parameters. Uses
|
None
|
Example:
1 2 3 4 5 6 7 8 9 | |
laser.measles.mixing.gravity.GravityMixing.get_migration_matrix()
Compute the gravity-based migration matrix.
Returns:
| Type | Description |
|---|---|
ndarray
|
Migration matrix of shape |
laser.measles.mixing.gravity.GravityParams
Bases: BaseModel
Parameters for the gravity migration model.
The gravity kernel computes migration flow as:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
float
|
Population source exponent (applied as a − 1 inside the kernel). |
required |
b
|
float
|
Population destination exponent. |
required |
c
|
float
|
Distance decay exponent — larger values suppress long-distance travel. |
required |
k
|
float
|
Average trip probability (scales the overall matrix). |
required |
Example:
1 2 3 4 5 | |