# What should be considered when selecting a windowing function when smoothing a time series?

If one wants to smooth a time series using a window function such as Hanning, Hamming, Blackman etc., what are the considerations for favouring any one window over another?

The two primary factors that describe a window function are:

1. Width of the main lobe (i.e., at what frequency bin is the power half that of the maximum response)
2. Attenuation of the side lobes (i.e., how far away down are the side lobes from the mainlobe). This tells you about the spectral leakage in the window.

Another not so frequently considered factor is the rate of attenuation of the sidelobes, i.e., how fast do the sidelobes die down.

Here's a quick comparison for four well known window functions: Rectangular, Blackman, Blackman-Harris and Hamming. The curves below are 2048-point FFTs of 64-point windows.

You can see that the rectangular function has a very narrow main lobe, but the side lobes are quite high, at ~13 dB. Other filters have significantly fatter main lobes, but fare much better in the side lobe suppression. In the end, it's all a trade-off. You can't have both, you have to pick one.

So that said, your choice of window function is highly dependent on your specific needs. For instance, if you're trying to separate/identify two signals that are fairly close in frequency, but similar in strength, then you should choose the rectangular, because it will give you the best resolution.

On the other hand, if you're trying to do the same with two different strength signals with differing frequencies, you can easily see how energy from one can leak in through the high sidelobes. In this case, you wouldn't mind one of the fatter main lobes and would trade a slight loss in resolution to be able to estimate their powers more accurately.

In seismic and geophysics, it is common to use Slepian windows (or discrete prolate spheroidal wavefunctions, which are the eigenfunctions of a sinc kernel) to maximize the energy concentrated in the main lobe.

• "two signals that are fairly close in frequency...you should choose the rectangular" Right, though it's usually better to simply increase the window size and then use a Hann/Gauss/Hamming/... window, if you need narrow main lobes. Rectangular is really quite awful in its side lobes and also doesn't lend itself well for overlapping windows, which work great with Hann. (That's of course only useful if you can afford to calculate big overlapping windows.) – leftaroundabout Sep 13 '11 at 10:46
• @leftaroundabout Of course, but usually comparisons are made for fixed window sizes. It's quite unfair to compare a window of one size with another of a different size. Yes, the rectangular is crappy for the most part, but it has uses in some cases. For the OP: I have a short, brief and non-math explanation on windows here on Stack Overflow. You might find it and the links in it (I've linked to Harris' paper, but I see Martin has it covered here) useful – Lorem Ipsum Sep 13 '11 at 14:07
• @LoremIpsum what exacty you mean by following statement "2048-point FFTs of 64-point windows." .. please suggest ? – user6363 Jun 1 '17 at 9:10

There's a large variety of windows compared in this seminal fred harris paper from 1978:

"On the use of Windows for Harmonic Analysis with the Discrete Fourier Transform"

Well worth a read!

Your question is slightly confusing because smoothing a time series is normally not used in the same context as windowing.

What you probably mean is that windowing a time series has the effect of smoothing (or smearing) the frequency response. You can find a description of the properties of most used windows and design trade-offs in almost any DSP book and wiki covers the topic as well http://en.wikipedia.org/wiki/Window_function. There is one criterion for choosing a window function which I haven't yet seen described in a DSP book in addition to the traditional ones of mainlobe width and sidelobe attenuation and that is computational convenience. For instance, in some applications a Hamming window is preferred because if you FFT a Hamming window you get only 3 non-zero taps!

You can of course smooth a time series by filtering it with a window function because a window function has a low-pass characteristic. But that is probably not what you're asking about.

• @leftaroundabout: " "two signals that are fairly close in frequency...you should choose the rectangular" Right, though it's usually better to simply increase the window size and then use a Hann/Gauss/Hamming/... window, if you need narrow main lobes. Rectangular is really quite awful in its side lobes and also doesn't lend itself well for overlapping windows, which work great with Hann. (That's of course only useful if you can afford to calculate big overlapping windows.)". Can you explain why overlapping works better with Hann than other windows? – niaren Sep 13 '11 at 11:47
• That statement was not meant to be exclusive. One experience I had, Hann worked best amongst the windows I tested, but there may be other cases where other windows do a better job. It's little more than a vague heuristic suspicion of mine that cosine-based windows should generally offer the best overlapping performance, because of \$\cos^2+\sin^2=1\$; so transients are registered quite equally strong regardless of where in the overlap they occur. – leftaroundabout Sep 13 '11 at 20:40
• Thanks. I'm not sure I understand your example. Anyway, I thought you referred to the fact that a 50% overlapping Hann window gives perfect reconstruction. – niaren Sep 14 '11 at 11:15