skfolio.utils.tools.half_life_to_decay_factor#
- skfolio.utils.tools.half_life_to_decay_factor(half_life)[source]#
Convert half-life to exponential decay factor.
The decay factor (\(\lambda\)) determines how much weight is given to past observations in exponentially weighted calculations. It is computed from the half-life using:
\[\lambda = 2^{-1/\text{half-life}}\]- Parameters:
- half_lifefloat
Half-life in number of observations. This is the number of observations for the weight to decay to 50%. Must be finite and positive.
- Returns:
- decay_factorfloat
The exponential decay factor (\(\lambda\)), satisfying \(0 \leq \lambda < 1\). Very small half-lives can round to zero, assigning all weight to the latest observation.
- Raises:
- ValueError
If
half_lifeis not finite and positive, or is so large that the decay rounds to one and new observations receive zero weight.
Examples
>>> half_life_to_decay_factor(40) 0.9828...