Smoothing

Shipping
smoothing

Low-pass / denoising: moving average, exponential, Gaussian, median, Savitzky-Golay

Signature

Inputs

  • signalSignalrequired

Outputs

  • resultSignal

Parameters

KeyTypeDefaultNotes
methodenummoving_averageone of: moving_average, exponential, gaussian, median, savitzky_golay
window_sizeint5
alphafloat0.2
sigmafloat1.0
orderint2

Description

The Smoothing node applies a low-pass / denoising filter to a Signal, attenuating high-frequency content and random fluctuations while preserving the underlying trend. It exposes five distinct algorithms via the method parameter: moving_average, exponential (EWMA), gaussian, median, and savitzky_golay. Each method is a self-contained smoother selected at execution time; the irrelevant parameters for a given method are simply ignored.

Behavior is governed by method-specific controls. window_size sets the number of samples in the moving-average, median, and Savitzky-Golay windows; alpha is the forgetting factor of the exponential filter; sigma is the Gaussian kernel standard deviation in samples; and order is the polynomial degree of the Savitzky-Golay fit. The output is a Signal on the same time base as the input — smoothing changes amplitude, not sample count or timestamps.

Units pass through unchanged: smoothing is a weighted linear (or, for median, order-statistic) combination of samples that all share one unit, so the result carries the input unit. For the linear methods the operation is a normalized convolution, so uncertainty ($\pm\sigma$) is reduced: averaging independent samples of equal variance shrinks the standard deviation toward . The median method is nonlinear and rejects outliers/impulses rather than averaging them.

Despite the exponential method being conceptually recursive, this node is stateless (stateful: false): it smooths each input block as a complete array and does not retain a running accumulator across graph ticks. For persistent, sample-by-sample continuous filtering use iir_filter.

Mathematics

Examples

Denoising a noisy sensor trace

Wire a noisy signal_generator (sine + noise_generator) into Smoothing with method = moving_average and window_size = 11. The output preserves the sine's shape while the broadband noise is cut by roughly in standard deviation. Increase window_size for smoother output at the cost of rounding sharp peaks.

Impulse rejection with median vs. mean

Feed a signal corrupted by sparse spikes into two Smoothing nodes, one median and one moving_average, both window_size = 5:

signal_generator -> smoothing(median,  window_size=5)  -> sink
signal_generator -> smoothing(moving_average, window_size=5) -> sink

The median branch removes the spikes cleanly; the moving_average branch smears each spike across five samples instead of eliminating it.

Applications

  • Pre-processing noisy measurement data (thermocouples, strain gauges, accelerometers) before derivative or peak-detection stages that amplify noise.
  • Savitzky-Golay smoothing of spectroscopy and chromatography peaks, preserving peak height and width while denoising.
  • Exponential (EWMA) trend tracking of slowly drifting process variables in control and monitoring dashboards.
  • Median filtering to remove salt-and-pepper glitches and dropout spikes from digitized or telemetered signals.

Neat

For a fixed window, **Savitzky-Golay** with polynomial `order` preserves the signal's peak height and higher moments far better than a moving average, because it fits a local polynomial instead of assuming the window is flat.

Because the linear smoothers are normalized convolutions, they reduce measurement uncertainty ($\sigma \to \sigma/\sqrt{N}$ for a length-$N$ average of independent samples) — a rare filter that actively *shrinks* the propagated $\pm\sigma$.

Known issues

Near the signal endpoints, symmetric windows (moving_average, gaussian, median, savitzky_golay) lack neighbors and rely on edge handling; the first and last $\sim W/2$ samples are less reliable than the interior.

The exponential method has an initialization transient: because the node is stateless, $y_0$ seeds from the first sample and small `alpha` values leave a visible warm-up region at the start of each processed block.

See also

smoothinglow-passdenoisingmoving-averagesavitzky-golayfilter