Skip to main content

ForecastEngine

Struct ForecastEngine 

Source
pub struct ForecastEngine { /* private fields */ }
Expand description

Forecast engine — produces predictions from historical data.

Uses a hybrid approach:

  1. Linear extrapolation from the slope of recent samples
  2. EWMA smoothing to reduce noise sensitivity
  3. Confidence from residual variance (how well linear fit matches data)

Implementations§

Source§

impl ForecastEngine

Source

pub const fn new() -> Self

Create a new forecast engine with default alpha (0.3).

Source

pub const fn with_alpha(alpha: f32) -> Self

Create with a custom EWMA alpha.

Source

pub fn forecast( &self, history: &VecDeque<MetricSample>, horizon: usize, ) -> Forecast

Forecast from a history of samples.

Combines linear extrapolation (for trend) with EWMA (for noise resistance). Confidence is derived from how well the linear model fits the data (R²-like measure from residual variance).

Outlier values are clamped to ±3 standard deviations from the mean before fitting, preventing a single extreme spike from dominating the forecast.

Trait Implementations§

Source§

impl Default for ForecastEngine

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.