Your Equation

Library / Signal processing and digital filters / DSP-34

Signal processing and digital filters

Five-point quadratic Savitzky–Golay smoothing

Quadratic least-squares smoothed value at the centre of five equally spaced samples, entered in time order as x₋₂ … x₂ (slots 0 to 4).

Ref
DSP-34
Rev
v1
Field
Signal processing and digital filters
Result
ŷ0 [V]

Fitting a quadratic to five equally spaced points by least squares and taking its value at the centre gives the weights (−3, 12, 17, 12, −3)/35. This Savitzky–Golay filter keeps the height and width of peaks that a moving average would flatten. It needs two samples on each side, so a real-time version has a two-sample latency.

Quadratic least-squares smoothed value at the centre of five equally spaced samples, entered in time order as x₋₂ … x₂ (slots 0 to 4). It needs two future samples, or two samples of output latency, and it preserves the shape of peaks better than a plain moving average.

Calculator

Solve for
V
V
−1010
V
−1010
V
−1010
V
−1010
V
−1010
  • Plain five-point mean2.2 V
  • Change from the raw centre sample−0.5143 V
  • Noise power gain, Σc²0.4857

What drives the result

Each variable is moved across its typical range while the others stay at the values above. The longest bar is the key driver.

Smoothed centre value (V) current value 0.4857 V
x0Sample at offset 0Key driver
−4.864.86
x-1Sample at offset -1
−3.293.57
x1Sample at offset 1
−3.293.57
x-2Sample at offset -2
−0.02861.69
x2Sample at offset 2
−0.02861.69
  • The smoothed centre value is 0.4857 V, −0.5143 V away from the raw centre sample of 1 V.
  • White noise power falls to 0.486 of its input value, while a quadratic trend passes through exactly, so a noiseless parabola is reproduced at its vertex.
Chart data as tables

Ranked variables

VariableTypical rangeLowest resultHighest resultSwing (V)Local stepChange in result
x0 Sample at offset 0−10 to 10 V−4.8574.8579.714+0.4 V+40 %
x-1 Sample at offset -1−10 to 10 V−3.2863.5716.857+0.4 V+28.2 %
x1 Sample at offset 1−10 to 10 V−3.2863.5716.857+0.4 V+28.2 %
x-2 Sample at offset -2−10 to 10 V−0.028571.6861.714+0.4 V−7.06 %
x2 Sample at offset 2−10 to 10 V−0.028571.6861.714+0.4 V−7.06 %

Sweep of Sample at offset 0

Sample at offset 0 (V)Smoothed centre value (V)
−10−4.857
−7.5−3.643
−5−2.429
−2.5−1.214
00
2.51.214
52.429
7.53.643
104.857

Sweep one variable

Smoothed centre value (V)Hover, touch, or use the arrow keys on the chart
−4−2024 −10−50510 Sample at offset 0 (V) now 0.4857

Variables and how each one contributes

ŷ0

Smoothed centre value

Result · V

What the equation gives you. Everything else feeds it.

x-2

Sample at offset -2

V · typical −10 to 10

The sample at offset -2 from the centre, in V. Is weighted by −3/35 in the smoothed value. Raising it by 10 % (to 4.4) moves the result by −7.06 %, from 0.4857 to 0.4514 V.

x-1

Sample at offset -1

V · typical −10 to 10

The sample at offset -1 from the centre, in V. Is weighted by 12/35 in the smoothed value. Raising it by 10 % (to 1.1) moves the result by +7.06 %, from 0.4857 to 0.52 V.

x0

Sample at offset 0

V · typical −10 to 10

The sample at offset 0 from the centre, in V. Is weighted by 17/35 in the smoothed value. Raising it by 10 % (to 1.1) moves the result by +10 %, from 0.4857 to 0.5343 V.

x1

Sample at offset 1

V · typical −10 to 10

The sample at offset 1 from the centre, in V. Is weighted by 12/35 in the smoothed value. Raising it by 10 % (to 1.1) moves the result by +7.06 %, from 0.4857 to 0.52 V.

x2

Sample at offset 2

V · typical −10 to 10

The sample at offset 2 from the centre, in V. Is weighted by −3/35 in the smoothed value. Raising it by 10 % (to 4.4) moves the result by −7.06 %, from 0.4857 to 0.4514 V.

Worked example with the values above

  1. Weighted terms: −3 × 4, 12 × 1, 17 × 1, 12 × 1, −3 × 4.
  2. Sum: 17.
  3. ŷ = 17 / 35 = 0.48571 V.

Assumptions and limits

  • Equally spaced samples, and noise that is uncorrelated from sample to sample.
  • A signal that is smooth over the filter span, so a local quadratic fit describes it.

Common mistakes

  • Using these filters at the ends of a record, where the window is incomplete.
  • Forgetting that centred filters add a delay of half the window length in real-time use.
  • Using a moving average where the sinc sidelobes let high frequencies leak through.

Statistics and uncertainty

Smoothing reduces random error and adds bias, which cannot both be small. A Savitzky–Golay fit lowers the noise variance by the factor Σc² (here 0.49) but flattens any curvature of higher order than a quadratic.

Where it is used

  • Smoothing sensor signals and estimating velocity from position records.
  • Predicting the noise reduction and frequency response of simple FIR smoothers.

Maths you need

  • Moving average: the mean of the latest M samples
  • Least-squares fit: the polynomial that minimises squared error
  • Noise power gain: Σh² for an FIR filter

Related formulas

Practise this formula