transitlos.scoring.frequency¶
Headway score H(headway): converts a service headway into a [0, 1] score.
H(headway) = 1 for headway <= 5 min
H(headway) = (headway / 5)^(-eps5) * exp(-(q / 2) * ln^2(headway / 5)) for headway > 5 min
with eps(headway) = p + q * ln(headway), eps5 = eps(5)
the closed-form solution of d(ln H) / d(ln headway) = -eps(headway): the elasticity of the score to the headway grows with the
headway. Defaults: parameters.RegionParameters (h_saturation_minutes, h_elasticity_p, h_elasticity_q).
frequency_score(headway_minutes, region='global', saturation_minutes=None, elasticity_p=None, elasticity_q=None)
¶
Compute H(headway), a [0, 1] frequency score from a service headway.
Below saturation_minutes (5 min) the score is exactly 1.0. Above it, the score follows the log-linear-elasticity
closed form described in the module docstring.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
headway_minutes
|
float
|
Scheduled or average headway in minutes. Must be
|
required |
region
|
str
|
Region key into |
'global'
|
saturation_minutes
|
float | None
|
Headway (min) at/below which score is 1.0.
Defaults to the region's |
None
|
elasticity_p
|
float | None
|
Intercept of |
None
|
elasticity_q
|
float | None
|
Slope of the same fit. Defaults to the region's
|
None
|
Returns:
| Type | Description |
|---|---|
float
|
A float in (0, 1]: 1.0 at/below the saturation headway, decaying |
float
|
smoothly (but never reaching exactly 0) as headway grows. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If headway_minutes is negative. |