The Savitzky-Golay Filter: Smoothing Signals Without Distorting Peaks
ENGPublished August 2026 · 5 min read
Smoothing filters are essential for cleaning high-frequency noise from experimental signals. However, standard moving average filters act like low-pass filters that flatten peaks, lower amplitudes, and artificially broaden FWHM values. For scientific analysis, we need a filter that preserves peak shapes. This is where the Savitzky-Golay (SG) Filter shines.
How the Savitzky-Golay Filter Works
Instead of calculating a simple average over a sliding window, the Savitzky-Golay filter fits a local polynomial of degree d to the data points inside the window using linear least squares. The filtered value at the center of the window is the value of the fitted polynomial.
Because the SG filter is linear, the fitting coefficients can be calculated in advance. This means the entire filter operates as a fast, single convolution matrix multiplication.
Why SG Preserves Peaks
Because the filter fits a polynomial (usually degree 2 or 4), it naturally preserves higher-order moments of the signal. Standard moving averages assume a flat signal (degree 0 polynomial), which is why they flatten peaks. SG filters preserve peak heights, centroids, and widths while removing high-frequency noise.
How to Choose SG Parameters
- Window Size (w): The number of points in the moving window. It must be an odd integer. As a rule of thumb, w should be between 1 and 1.5 times the FWHM of your narrowest peak (exceeding 2x FWHM risks eroding peak height).
- Polynomial Order (d): Typically set to 2 or 4. A higher order fits sharp peaks better but removes less noise; a lower order smooths more aggressively but can start to flatten sharp peaks.
The AltaiPlot Advantage: Visual Smoothing Control
Tuning filter window size in Python code often results in "blind smoothing," where you might accidentally erode important peak heights or broaden widths without noticing. AltaiPlot offers a dedicated Smooth Tool in the Analysis Toolbar:
- Live Preview Overlay: Toggle the original signal and the smoothed curve on top of each other as you adjust parameters.
- Real-time Computation: The Savitzky-Golay filter computes instantly on the GPU as you change window size and polynomial order, letting you visually assess the impact on peak shapes before applying.
- Multiple Filter Types: Beyond SG, choose from Moving Average, Exponential Moving Average, Median, and Gaussian Blur — all with the same interactive preview.