rolling
rolling
Section titled “rolling”The rolling module provides rolling-window aggregations and a first-order
linear recurrence helper. All implementations route through dedicated
intrinsics for performance.
Import
Section titled “Import”use std::core::utils::rollingWindowed Aggregations
Section titled “Windowed Aggregations”Each rolling function takes a numeric series and a window period, and
returns a windowed output of the same shape.
| Function | Description |
|---|---|
rolling_sum(series, period) | Rolling sum over a fixed-size window |
rolling_mean(series, period) | Rolling arithmetic mean |
rolling_std(series, period) | Rolling standard deviation |
rolling_variance(series, period) | Rolling variance (= rolling_std^2) |
use std::core::utils::rolling
let prices = [100.0, 101.0, 102.5, 101.8, 103.0, 104.2]let sma_3 = rolling::rolling_mean(prices, 3)let std_3 = rolling::rolling_std(prices, 3)Linear Recurrence
Section titled “Linear Recurrence”rolling::linear_recurrence(input, decay: number, initial_value: number) -> Array<number>
Section titled “rolling::linear_recurrence(input, decay: number, initial_value: number) -> Array<number>”Apply a first-order linear recurrence across input:
y[t] = y[t-1] * decay + input[t]This is the kernel under exponential moving averages, IIR low-pass filters, and many other smoothing schemes.
use std::core::utils::rolling
let signal = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0]let smoothed = rolling::linear_recurrence(signal, 0.9, 0.0)