# How to interpret the effect of different windows in short time fourier transform?

There are many categories of windows, e.g., rectangular, Gaussian, and triangular. What are their effects on STFT?

• Also have a look here.
– jojek
Nov 9 '17 at 12:54

A widnow $$w[n]$$ truncates and weights (tapers) an input signal $$x[n]$$, to produce $$v[n] = x[n]. w[n]$$., for subsequent spectral analysis of $$x[n]$$. A windows's effect on the input signal's true spectrum $$X(e^{j\omega})$$ is described by a convolution of $$X(e^{j\omega})$$ with $$W(e^{j\omega})$$ (window's Fourier transform);

$$V(e^{j\omega}) = \frac{1}{2\pi} \int_{-\pi}^{\pi} W(e^{j\theta})X(e^{j (\omega -\theta)}) d\theta$$

due to this convolution, two main effects are observed on $$X(e^{j\omega})$$.

1 - smoothing (smearing) of $$X(e^{j\omega})$$ due to the main lobe width of $$W(e^{j\omega})$$, which results in a loss of spectral resolution.

2- spectral leakage due to peak side lobe of $$W(e^{j\omega})$$, which results in a loss of weak components shadowed by nearby stronger ones.

Main lobe width of any window type is primarily determined by its length. Increasing the length of any window will therefore decrease its main lobe width (hence increase its spectral resolution capability)

A rectangular window has the narrowest main lobe width and the highest peak side lobe, compared to all other windows. And the remainig window types perform a tradeoff between mainlobe width and the peak side lobes.

Peak side lobe is primarily determined by windows's shape. So by changing the shape (type) of the window you adjust it's leakage amount.

The rectangular window is just what, when we have truncated the data, while the other windows provide some data weighting. From their effects on the frequency spectra, The advantage of using a window other than rectangular is to have lower sidelobes.

However, the disadvantage is a loss in frequency resolution, from $\Delta \omega = 4\pi / N$ for the rectangular window to $\Delta \omega = 8\pi / N$ and $16\pi / N$ for Gaussian and Triangular windows respectively.

In addition to what's already been said, using a rectangular window also results in the minumum possible noise floor, which is desirable in some applications.

With regard to obtaining the best amplitude/magnitudes estimates, you should consider using some of the flat top windows, which are designed specifically for this purpose. However, they have a wide main lobe, and thus poor frequency resolution, so they're not suitable for signals where you have sinusoids that are close in frequency.

Anyway, see here http://zone.ni.com/reference/en-XX/help/371361H-01/lvanlsconcepts/char_smoothing_windows/ or here https://en.wikipedia.org/wiki/Window_function if you interested in the theory.

[EDIT 2017-11-10: added details one the used of inverses] Their first effect, in the time domain, is to localize, or (weakly) stationarize the data, as a preprocessing before applying the FFT.

Then in the analysis side, their frequency effect is the same as when used for an FFT, ad detailed on other answers.

Last, in the synthesis side, a different window can be used when recovering a signal from a selection of chunks in the time-frequency domain.

This is used in practice, for instance in image compression. One wavelet/window type is used for the analysis or image decomposition, better at compacting information. Then, this information is quantized, and another wavelet/window is used for decompression: it is smoother, and attenuate, visually, quantization artifacts. Here, the whole transform is not redundant, and this is called biorothogonality.

In the redundant setting, certain analysis windows admit a closed-form inverse with the same window, but this is not always the case, as you c an see from the following picture given in Duality for Frames, 2016, with the analysis window on the left, and the synthesis one on the right. • Isn't using a different window for the synthesis phase undesirable because you're more likely to introduce certain digital artifacts that were not present in the original signal? Nov 9 '17 at 22:01
• Tough comment for a simple answer. Since the STFT is redundant, it may admit several inverses. So if you don't change STFT coefficients, those other inverses are just perfect. So you can design other inverses, that are more optimal in some sense. Those could be useful, for given purposes, but not use for direct inverses. However, when doing processing in the STFT domain, you may want reconstructed data more precise in time, or in frequency, for detection purposes Nov 9 '17 at 22:21
• The article you linked to looks very theoretical and I suppose it may be useful in certain situations (though I don't pretend to even understand what it involves :) Nov 10 '17 at 7:09
• Now that you brought this up and since I'm doing some audio manipulations in the frequency domain (which sometimes/often sound bad when inverted back), I think I might give this idea a try. Nov 10 '17 at 8:33