Skip to main content

decayed

Function decayed 

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

Compute a decayed confidence value.

base is the stored value; age_days is the time elapsed since the value was last written (typically now - max(created_at, confidence_decayed_at)); half_life_days is the namespace-policy override or crate::confidence::DEFAULT_HALF_LIFE_DAYS.

Formula: base * 2^(-age / half_life), i.e. base * exp(-age * ln(2) / half_life). Honours the standard half-life convention: at age = half_life, the value collapses to 0.5 * base. Clamped to [0.0, 1.0]. Negative age_days is treated as 0.0 (no future-dated decay). half_life_days <= 0 is treated as f64::EPSILON so the divisor never goes to zero (the value collapses to 0 in that case, which is the documented degenerate-input contract).