# Smoothing a discrete function with point wise variances

In Stark's Introduction to numerical methods  it suggests fitting local polynomials to smooth discrete data before the Fourier transform using least squares minimisation. This gives the following rules for degree three five-point smoothing:

for the first two entries: $$g_1 = \frac{1}{70} (69 f_1 + 4 f_2 - 6 f_3 + 4 f_4 - f_5) \\ g_2 = \frac{1}{35} (2 f_1 + 27 f_2 + 12 f_3 - 8 f_4 + 2 f_5) \\$$

for the last two entries:

$$g_{N-1} = \frac{1}{35} (2 f_{N-4} - 8 f_{N-3} + 12 f_{N-2} + 27 f_{N-1} + 2 f_{N}) \\ g_{N} = \frac{1}{70} (- f_{N-4} + 4 f_{N-3} - 6 f_{N-2} + 4 f_{N-1} + 69 f_{N})$$

and for all other entries:

$$g_{n} = \frac{1}{35} (-3 f_{n-2} + 12 f_{n-1} + 17 f_{n} + 12 f_{n+1} - 3 f_{n+2})$$

Would a weighted least squares approach following this idea be valid (what would the formulae be?) or are there more widely recognised approaches for smoothing functions with known variances?

Other then the endpoints, this is really just an FIR filter. You can easily assess the impact of smoothing on the spectrum by looking at the Fourier Transform of the impulse response of the filter . In this case it's a notch filter which seems like an odd choice.

In general smoothing is in many cases similar or equivalent to a lowpass filter operation and will in general decrease high frequency content of the signal. The "best" choice of low-pass will always depend on your specific application and requirements.

• LOESS is a pretty popular method in statistics for doing what you describe. it's based on observatons rather than functions but you can use the value of the functions at the particular point you want to smooth. See this but there are probably better ones because it's old. statsdirect.com/help/nonparametric_methods/loess.htm – mark leeds Jan 22 '20 at 13:08

The filter you described with coefficients

$$[-3\,,12\,,17\,,12\,,-3]/35$$

is exactly one known design. It exists under different names, and can be obtained specialized as a Savitzky-Golay filter of (polynomial) order $$O=3$$ and frame length $$L=5$$, and it does indeed consist of least-squares fit on regularly spaced samples (last column of the Table in section Weighted (Savitzky-Golay) Filters of the above link).

I will come back with more details and references on those families of local polynomial approximations.