2012-04-18

DFT and the Window Spectrum

In case I forget again why the window spectrum is computed when doing DFT, the answer is that discretisation  leads to aliasing artefacts.

Consider the DFT of a x(t)=1. Its DFT is calculated by calculating the sum sin(2 pi f t)*x(t) and cos(2 pi f t)*x(t) individually, then squaring the resulting sums, add them together, then  take the square root. Since x(t) = 1, for any frequency you are essentially summing cos(t) and sin(t), which you expect to be zero, and thus the power spectrum should be 0 for any frequency.

If you actually do this with, you will find that unless the points in time where sampling occurs covers an integer number of wavelengths, and is coherent in phase, i.e. sampling occurs in the same phase of each cycle, you will find that you don't get 0. You might get 0.1, 0.15, 0.09, 0.01, etc, but not 0. This is made more obvious by non-uniformely sampled data, such as those you might get in the real world.

This present a problem: the residue can produces peaks where there would otherwise be none, and this is more pronounced for lower frequency, because their wavelengths are longer and thus less likely to fit perfectly inside the window.

One way of rectifying this issue is to compute a correction coefficient c(f)=1-w(f) where f is the frequency, w(f) the window spectrum. The "corrected" power spectrum can then be calculated as correctp(f) = p(f) * c(f), where p(f) is the power spectrum.

I should add that the above method is not at all mathematical. It is chosen because any correction strategy that involves dividing by w(f) is unstable as sometimes w(f) gets very close to 0. Simply subtracting w(f) from p(f) won't work either because p(f)'s magnitude clearly depends on x(t) whereas  w(f) doesn't.

An obvious failure of the above correction is that it doesn't make the residue disappear - it only reduces it. A superior method would correct the DFT for a DC signal so it is 0 everywhere.

Update

The obvious answer is to simply normalise x(t) so the maximum amplitude is 1.0. Then the window power can simply be subtracted. Duh.

Cheers,
Steve