Skip to main content

decay_factor

Function decay_factor 

Source
pub fn decay_factor(age_days: f64, half_life_days: f64) -> f64
Expand description

Pure decay function. Returns a multiplier in [0.0, 1.0] for an observation of age_days against half_life_days. Uses the classical exponential decay: factor = 0.5 ^ (age / half_life).

Properties (locked by unit tests):

  • age = 0 → factor = 1.0 (full weight)
  • age = half_life → factor = 0.5
  • age = 2*half_life → factor = 0.25
  • age = 10*half_life → factor ≈ 0.001 (effectively gone)
  • negative age (clock skew, future-dated entry) → factor = 1.0 (defensive: don’t amplify boosts for future timestamps)
  • half_life ≤ 0 → factor = 1.0 (decay disabled)