nx_forecast.nx
buildroot/runtime/nx_forecast.nx
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
imports: syscalls.nx
imported by: nx_forecast_test.nx
structs
| 42 | struct SES |
| 72 | struct Holt |
consts
| 38 | const NX_FORECAST_Q: i64 = 16384 // Q14 |
functions
| 48 | func nx_forecast_ses_init(ses: *SES, alpha_q14: i64) -> i64 called by 1: main |
| 55 | func nx_forecast_ses_observe(ses: *SES, x: i64) -> i64 called by 1: main |
| 66 | func nx_forecast_ses_predict(ses: *SES) -> i64 called by 1: main |
| 81 | func nx_forecast_holt_init(h: *Holt, alpha_q14: i64, beta_q14: i64) -> i64 called by 1: main |
| 91 | func nx_forecast_holt_observe(h: *Holt, x: i64) -> i64 called by 1: main |
| 113 | func nx_forecast_holt_predict(h: *Holt) -> i64 called by 1: main |
| 117 | func nx_forecast_holt_predict_h(h: *Holt, steps: i64) -> i64 called by 1: main |
| 126 | func nx_forecast_ar_predict(history: *i64, coeffs_q14: *i64, p: i64) -> i64 |
| 136 | func nx_forecast_ar_rollout(history: *i64, coeffs_q14: *i64, p: i64, |