Windowed Max

Shippingstateful
windowed_max

Sliding-window peak tracker: abs_max, signed_max, signed_min, or running_max

Signature

Inputs

  • signalSignalrequired

Outputs

  • peakSignal

Parameters

KeyTypeDefaultNotes
modeenumabs_maxone of: abs_max, signed_max, signed_min, running_max
window_sizeint256

Description

Windowed Max is a sliding-window peak tracker. For each incoming sample it emits the extremal value observed over the most recent window_size samples of the input signal, according to the selected mode. The four modes are: abs_max (largest magnitude , returned with its original sign preserved), signed_max (largest algebraic value ), signed_min (smallest algebraic value ), and running_max (a cumulative maximum over the entire history, ignoring window_size).

The node is stateful: it holds a WMaxState containing the ring of recent samples (or, for running_max, a single accumulator). Output is produced sample-by-sample and is causal — the peak at index depends only on samples up to and including . Before the first window_size samples have arrived the window is not yet full, so early outputs reflect the extremum over however many samples have been seen so far.

Units are passed through unchanged: the peak carries the same physical unit as the input, since selecting an extremum is dimensionally neutral. For uncertainty, the output inherits the standard deviation of whichever sample won the extremum comparison — the result is a selected value, not an arithmetic combination, so no error propagation formula is applied and no variance is accumulated across the window.

Unlike envelope or smoothing, the output is not filtered or interpolated; it is a hard, exact selection of one existing sample value per step, giving the characteristic flat-then-step staircase as the winning sample enters and exits the window.

Mathematics

Examples

Peak-hold on a decaying oscillation

Feed a damped sinusoid into windowed_max with mode = abs_max and window_size = 64. The peak output tracks the local envelope: it holds the largest recent magnitude (sign preserved) for up to 64 samples, then steps down as that peak scrolls out of the window. This yields a discrete, lag-bounded envelope useful for level metering.

Session all-time maximum

With mode = running_max, window_size is ignored and the node reports the cumulative maximum since the start of the stream:

x    = [3, 1, 4, 1, 5, 9, 2, 6]
peak = [3, 3, 4, 4, 5, 9, 9, 9]

Use this to latch the highest value a quantity has reached during a simulation or acquisition run.

Applications

  • Audio and vibration level metering: bounded-lag peak-hold on a signal magnitude for VU/PPM-style displays.
  • Structural and mechanical testing: latching the maximum load, stress, or acceleration reached during a run via `running_max`.
  • Envelope estimation for AM demodulation or transient detection, feeding a downstream threshold or `schmitt_trigger`.
  • Real-time monitoring of sensor extrema (peak temperature, pressure, current) over a rolling observation window.

Neat

`abs_max` returns the winning sample with its *original sign*, so a large negative excursion appears as a negative peak — it is a signed magnitude tracker, not a rectifier followed by a max.

Because the output is always a value that actually occurred in the input window, its attached uncertainty $\sigma$ is that of a single real sample; no window-averaging shrinks or inflates the reported error.

Known issues

During the initial fill (fewer than `window_size` samples seen), the reported extremum is taken over a partial window, so early outputs are not directly comparable to steady-state values.

For `abs_max`, exact ties in magnitude between a positive and negative sample resolve by scan order, so the emitted sign can depend on sample position within the window.

See also

peaksliding-windowenvelopestatefulmaxsignal