code wiki / (root) / nx_forecast.nx

nx_forecast.nx

buildroot/runtime/nx_forecast.nx

4081 B151 linesdepth 3pulls 3 transitivereach 1 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_forecast.nx -- time-series forecasting primitives. Classical recursive forecasters complementing nx_kalman: 1. Simple Exponential Smoothing (Brown 1956) s_t = alpha * x_t + (1 - alpha) * s_{t-1} 2. Holt Double Exponential (Holt 1957) l_t = alpha * x_t + (1 - alpha) * (l_{t-1} + b_{t-1}) b_t = beta * (l_t - l_{t-1}) + (1 - beta) * b_{t-1} forecast(h) = l_t + h * b_t 3. Autoregressive AR(p) forecaster x_t = phi_1 x_{t-1} + ... + phi_p x_{t-p} All smoothing parameters in Q14 fixed-point. Pure i64. What this unlocks: + sensor smoothing without state-model (lighter than Kalman) + trend extrapolation + AR-model rollout for short-horizon prediction + anomaly detection (deviation from forecast) Sibling of nx_ts.nx (which handles Unix-epoch <-> calendar); this module forecasts numeric time series. genealogy_id: brown_1956_ses + holt_1957_double_exp + box_jenkins_1970 lineage_id: recursive_exponential_smoother + autoregressive_predictor

dependencies 1 imports · 1 importers

syscalls.nx nx_forecast.nx nx_forecast_test.nx

imports: syscalls.nx

imported by: nx_forecast_test.nx

structs

42struct SES
72struct Holt

consts

38const NX_FORECAST_Q: i64 = 16384 // Q14

functions

48func nx_forecast_ses_init(ses: *SES, alpha_q14: i64) -> i64
called by 1: main
55func nx_forecast_ses_observe(ses: *SES, x: i64) -> i64
called by 1: main
66func nx_forecast_ses_predict(ses: *SES) -> i64
called by 1: main
81func nx_forecast_holt_init(h: *Holt, alpha_q14: i64, beta_q14: i64) -> i64
called by 1: main
91func nx_forecast_holt_observe(h: *Holt, x: i64) -> i64
called by 1: main
113func nx_forecast_holt_predict(h: *Holt) -> i64
called by 1: main
117func nx_forecast_holt_predict_h(h: *Holt, steps: i64) -> i64
called by 1: main
126func nx_forecast_ar_predict(history: *i64, coeffs_q14: *i64, p: i64) -> i64
136func nx_forecast_ar_rollout(history: *i64, coeffs_q14: *i64, p: i64,
called by 1: main calls 1: nx_forecast_ar_predict