name: op-win-ewma
description: Exponentially weighted moving average; s_i = alpha*x_i + (1-alpha)*s_{i-1}.
kind: operator
category: WIN
operator: WIN_EWMA
type: reference
applies_to: process, compose, predict
examples_tags: [time-series, window-operator, buffered-pipeline]
Window operators emit row-level values; they do not produce Response.Components.
Use when
Adds a smoothed series: each new value counts for a fixed share w, the previous smoothed level for 1 - w, so older values fade.
Questions it answers:
- What is the underlying level of daily demand once day-to-day noise is damped?
- Is the smoothed defect rate drifting up over recent batches?
Use something else:
WIN_MOVING_AVGwhen you want every row in a fixed window to count equally.
Params
| Name | Type | Default | Description |
|---|---|---|---|
alpha | float | — | (0, 1]; higher weights recent rows. |
decay | float | — | carry-over [0, 1); alpha = 1 − decay. |
Give EXACTLY ONE of alpha / decay (manifest exactly_one_of: smoothing; a Recommend draft names alpha). Either may be an expression ("params.d", "sweep_axis(\"fit\", \"tv\")"), its value range-checked.
partition_by (carve), order_by (≥1, required, any type but set_* (PULSE_WINDOW_INVALID) or vec_* (PULSE_VECTOR_FIELD_NOT_SCALAR)), frame (REQUIRED {mode: "rows"}; unread — manifest ignores_frame). field (required, numeric).
Inputs
field — admitted types: see ## Contract.
Output
One float64 per row written to label (default WIN_EWMA_<field>). Recurrence seeds from the first non-null value in the partition.
Reading the output
value: A smoothed level of the field: s = alpha * current + (1 - alpha) * previous s, seeded with the partition’s first value present. A value k rows back carries weight alpha * (1 - alpha)^k, so alpha near 1 follows the latest value closely and alpha near 0 changes slowly.- Caveat: The seed enters at full weight, so the start of each partition leans on the first value: with alpha 0.1 it still carries about 35% of the weight ten rows later (0.9^10). Read the early rows with care.
Contract
- Types (
field):date,f32,f64,u16,u32,u4,u64,u8; any other scalar type isPULSE_FIELD_TYPE_UNSUPPORTED. - Weight: no weighted form and no slot weight; a request weight is
PROCESSING_CONFIG, an instance default is skipped. - Streaming: buffered only.
Gotchas
- Both, neither, or a value out of range →
PULSE_WINDOW_INVALID(predict and runtime alike). alpha = 1 − decayfrom the decay’s EXACT decimal:decay: 0.7smooths bit-identically toalpha: 0.3(not float1 − 0.7).decay: 0isalpha: 1(identity).- Rows preceding the first non-null emit
null(no seed). - Null values emit
null; state survives to the next non-null row. - Result rows are NOT reordered — use
sort. - For media adstock use
WIN_DISTRIBUTED_LAG: it starts from zero, with geometric or Weibull kernels. - Regressions and post-window formulas may read the label (
regression-model-options).
See
pulse_examples_search tags=[time-series]- Skills:
window-design,op-win-moving-avg,op-win-running-avg,op-win-distributed-lag