Savitzky-Golay Filter Calculator

Smoothing and derivatives by local polynomial fits.

  • Coefficients shown
  • Noise gain
  • Derivatives too
A soft clay table with a jagged ridge of small rounded bumps, a smooth rounded ribbon curving over it, and a few loose rounded beads.

The guide

A local polynomial fit is just a fixed set of weights, and that is why it smooths without flattening peaks

Fit a small curve to each stretch of a noisy series and keep its centre: the whole job collapses into one row of numbers, which also hands you derivatives for free.

  • 0.6969 noise gain of the 5-point quadratic filter
  • 0.5054 noise gain of the 9-point quadratic filter
  • 0.3333 noise gain of a 9-point moving average
  • 0.928 peak height kept by a 9-point moving average
  • 0.9963 peak height kept by a 9-point quadratic filter
Read the full guide Fold the guide 7 min · 15 sources

Take five readings in a row: 2, 4, 3, 9, 5. The middle one, 3, looks low next to its neighbours, and the 9 beside it looks suspiciously high. A plain average of the five gives 4.6. A quadratic fitted to all five by least squares and read off at the centre gives 5.314. Those two answers differ because the second one respects the shape of the data, and that difference is the whole subject.

A fit that turns into a row of weights

The Savitzky-Golay filter works on evenly spaced data. For each point it takes a window of neighbours, fits a low-degree polynomial to them by linear least squares, and keeps the fitted value at the centre. Then it slides one place along and does it again. Done naively that sounds expensive, one regression per point. It is not, and the reason is worth seeing.

Least squares is linear in the data. Whatever the window holds, the fitted centre value is a fixed weighted sum of the values in it. The weights depend only on the window length and the degree, never on the numbers being smoothed. For five points and a quadratic they are -3, 12, 17, 12 and -3, divided by 35. Work it through on the readings above: minus 6, plus 48, plus 51, plus 108, minus 15 is 186, and 186 over 35 is 5.314.

Those weights come from the normal equations. Build the matrix whose columns are the powers of the offsets, a Vandermonde matrix, multiply it by its own transpose and invert. For a cubic over five points that product has rows 5, 0, 10, 0 and 0, 10, 0, 34 and 10, 0, 34, 0 and 0, 34, 0, 130. The row of the pseudo-inverse that picks out the constant term is your smoothing row. The same sum, slid along the series, is a convolution with a finite number of weights, which is why signal processing calls it a finite impulse response filter.

One detail trips people up. Written as above, with the weights lined up against the data in the order printed, the operation is a correlation. A textbook convolution flips one of the two sequences first. For a symmetric smoothing row the flip changes nothing. For a first derivative the row is antisymmetric, the flip reverses its sign, and a slope comes out upside down. Any program that applies a derivative row without saying which convention it follows is a coin toss.

Why the degree matters more than the window

Noise first. If every reading carries independent noise of the same size, the noise in a weighted sum has a spread equal to the original spread times the square root of the sum of the squared weights. Call that the noise gain. A 9-point moving average has weights of one ninth each, so its gain is 0.3333: two thirds of the noise spread is gone. A 5-point quadratic filter gives 0.6969, a 7-point one 0.5774 and a 9-point one 0.5054.

A longer window removes more noise, but so does a lower degree. Hold the window at nine points and the gain climbs from 0.3333 for a straight average to 0.5054 for a quadratic, 0.6459 for a quartic and 0.7869 for a sixth-degree fit. Each extra degree lets the polynomial follow the data more closely, and following the data closely includes following its noise.

The price of the plain average is paid at the peaks. Take a noise-free Lorentzian line, the bell shape with heavy tails that physicists use for spectral lines, with a half-width of 0.45 sampled every 0.05. A 9-point moving average lowers its top to 0.928 of the true height. A 9-point quadratic filter keeps 0.9963. A quartic keeps 0.9998. The average treats the window as flat, so it cuts the top off anything narrower than the window. The polynomial can bend, so it can bend over a peak.

This is the trade the method makes, and it is the only reason to prefer it to the average. You choose how much curvature the window may contain. Raise the degree to protect narrow features, raise the window to calm the noise, and expect to pay in one currency or the other.

Derivatives from the same fit

A polynomial that has been fitted can be differentiated exactly. So the row that gives the fitted centre value has a sibling that gives the fitted slope there, and another that gives the curvature. For five points and a cubic the slope row is 1, -8, 0, 8 and -1, divided by 12 and by the spacing h. The second derivative row for a quadratic is 2, -1, -2, -1 and 2, divided by 7 and by h squared. In general the d-th derivative row carries the factor d factorial over h to the power d.

Forgetting the spacing is the most common mistake in practice. The rows are written for unit steps. If the readings are taken every half unit, the slope row returns the change per step, and it must be divided by 0.5 to become a change per unit. A check you can reproduce in the tool: sample y = 0.5 x squared minus 1.6 x plus 2 at steps of 0.5. At x = 1 the true slope is minus 0.6. With the division the filter returns minus 0.600. Without it, minus 0.300.

There is a pleasing coincidence worth knowing. The 5-point cubic slope row is the same set of numbers, one twelfth, minus two thirds, zero, two thirds, minus one twelfth, as the fourth-order central finite difference. Fitting a cubic over five points and differentiating it is the same as the classical high-accuracy difference formula. The filter is not a new kind of derivative. It is the ordinary one, made by a principled choice of weights.

Differentiating noisy data is hard because a difference of neighbours amplifies whatever is uncorrelated between them. The fitted-polynomial rows tame that, but they do not remove it. A slope from a 9-point window is still noisier than a smoothed value from the same window, and a second derivative is noisier again.

Peaks, zeros and what two passes change

A smooth curve reaches its maximum where its slope crosses zero from positive to negative. On a noisy trace, the highest raw point is a poor guess for that place because it is simply the point that received the luckiest noise. The zero crossing of the filtered slope uses the whole window. In the seeded example on this page, a noisy Lorentzian whose true peak sits at 0, the highest raw reading lies at minus 0.100 and the 9-point cubic slope crosses zero at minus 0.042. Either could differ for another noise draw, which is exactly the point of seeding it.

The same idea finds the end point of a titration, where the second derivative of the curve crosses zero at the inflection. The method does not know what the data mean. It will happily put a zero crossing on a ripple that is noise.

What about running the filter twice? Two passes of a 3-point average are the same as one pass of the weights 1, 2, 3, 2 and 1, divided by 9. The noise gain falls from 0.5774 for one pass to 0.4843 for two, and the effective window has grown to five points. You get more smoothing, with a bell-shaped weight pattern instead of a flat one, but you also get the extra flattening a wider window brings. Two passes do not buy back the peak.

The edges deserve a sentence. A window of nine needs four neighbours on each side, so the first four and last four points have no centred window. One option leaves them unfiltered, which matches the formula as published. Another fits one polynomial to the first window and one to the last and reads the edge points from those. That is a different method with different behaviour, and the page labels it so.

What this calculator will and will not do

Paste an evenly spaced series, pick an odd window, a degree below the window length and a derivative order up to the degree. The page prints the weights as whole numbers over one divisor, applies them, reports the noise gain, and marks where the derivative crosses zero. It refuses an even window, a degree the window cannot support, and an x column whose steps are not equal.

It does not handle uneven spacing, windows that adapt to the data, two-dimensional images or filter design in the frequency domain. It does not tell you whether smoothing is appropriate for your data, and a filtered curve is an estimate, not a measurement. Heavy work runs in a separate worker thread so the page stays responsive, and numbers are formatted with the browser’s own number formatting.

Nothing you paste leaves the device. The weights are found by exact fractions up to a window of 31 and by a stated floating-point solve beyond that, and every printed table can be compared with the ones in the source.

Sources

Every source consulted for this guide. Links checked November 12, 2026.

  1. Savitzky-Golay filter Wikipedia (CC BY-SA)
  2. Moving average Wikipedia (CC BY-SA)
  3. Linear least squares Wikipedia (CC BY-SA)
  4. Polynomial regression Wikipedia (CC BY-SA)
  5. Convolution Wikipedia (CC BY-SA)
  6. Numerical differentiation Wikipedia (CC BY-SA)
  7. Finite difference coefficient Wikipedia (CC BY-SA)
  8. Vandermonde matrix Wikipedia (CC BY-SA)
  9. Cauchy distribution Wikipedia (CC BY-SA)
  10. Smoothing Wikipedia (CC BY-SA)
  11. White noise Wikipedia (CC BY-SA)
  12. Moore-Penrose inverse Wikipedia (CC BY-SA)
  13. Finite impulse response Wikipedia (CC BY-SA)
  14. Web Workers API MDN Web Docs (CC BY-SA)
  15. Intl.NumberFormat MDN Web Docs (CC BY-SA)