# 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"

• 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