General > General Technical Chat
FFT window function calculation detail
<< < (4/8) > >>
gf:

--- Quote from: Nominal Animal on November 24, 2022, 12:42:28 am ---Small changes in DFT length \$N\$ can be confusing, because spectral leakage affects only signals whose wavelength is not an exact multiple of \$N\$.

--- End quote ---

It depends on the window function. Leakage is zero for those frequencies, where the frequency response of the spectrum analysis filter has zeros. And it is the window function, which determins the spectrum analysis filter which is shifted to and applied at each frequency bin. For a rectangular window, the spectrum analysis filter of each bin happens to have zeros at the frequencies of all other bins. A Hann window, for instance, does not have zeros at the two immediate neighbor bins, but otherwise still at all other bins, granted the "periodic" variant of the Hann window is used. And for other window functions, it is yet different.


--- Quote ---The signal that yielded a perfectly crisp peak at DFT length \$N\$ will be spread out in DFT length \$N+1\$ or \$N-1\$.

--- End quote ---

One point of view is that frequencies spread out to other regions in the spectrum. Another point of view for leakage is that each bin's spectrum analysis filter has a particular frequency response, and all frequencies falling into the passband are accumulated by the bin. At the end the result is the same (i.e. a convolution in the frequency domain), but I find the latter more intuitive to understand, due to the analogy with a SA.
electr_peter:
I agree to points above from @Nominal Animal (scaling for power, symmetry, zero padding effect), also to a point in previous post about widening with zeros. I meant adding zeros to a window weights, not outside window. I get same results from your example and effect of zero padding on front or back is clear to me.

My interpretation of your example - for 9 sampled points, take a variant of triangle window weights with no zeros (so that no information is lost in such a small sample) and calculate FFT. For small \$N\$ triangular window weights with no-zeros probably is better (IMO it is a compromise in a desperate situation). For non-triangular window I would use first filter weight as zero.

My choice of triangular (Bartlett) window as the basic example is not the best as there are multiple definitions for discrete weights calculation. Hanning window function can used as a basis for discussion as it has only 1 formula that I am aware of.

In the same source linked above, section C, almost all of the windows have similar definitions for \$w_j, j = 0, \dots, N-1,\$ resulting in \$w_0 = 0\$. Also, weights are symmetric \$w_j = w_{N-j}\$. This is so called DFT-symmetry.

Part II. Harmonic analysis of finite-extent data and the DFT, pages 172-173 from
"On the Use of Windows for Harmonic Analysis With the Discrete Fourier Transform", discusses concept of DFT-even in more detail. It implies \$w_0 = 0\$ and \$w_{N-1} <> 0\$ with DFT symmetry \$w_j = w_{N-j}, w_0 = w_N\$

Window function (i.e. continuous) has zero at both ends, definitely (exluding Hamming and some others). Discrete weights for DFT should have zero weight on one end only.
gf:

--- Quote from: SiliconWizard on November 22, 2022, 04:57:10 am ---Yes it should be symmetric.

--- End quote ---

A symmetric FIR filter is linear-phase. Consequently, a symmetric window function results in a linear phase spectrum analysis filter.

Btw, searching the web, there also seem to exist use cases for asymmetric window functions.


--- Quote from: electr_peter on November 22, 2022, 11:12:00 am ---Window function gateway Matlab allows both window versions for most filter with opt parameter. "Symmetric" has zero on both ends, "periodic" has zero on one end.
Still not sure which is better after looking through DFT definitions. Difference is only +/- 1 sample, but that is not insignificant.
Considering that windowed function is viewed as repeating function from DFT perspective, case can be made for both zero - nonzero & zero - zero type windows.

--- End quote ---

The "periodic" variant honors the circular/periodic nature of a DFT, assuming that the (N+1)th point is identical to the first point of the next period. Therefore the (N+1)th point is excluded, because the first point is already included. I.e. hanning(N,"periodic") is the same as hanning(N+1,"symmetric")(1:end-1). The same equality can be used to calculate periodic versions for some other window functions, where Matlab/Octave don't provide a symmetric/periodic option.
Nominal Animal:
There is no Hanning window function!  There is Hann, and there is Hamming.  They are closely related, but different.
Nominal Animal:

--- Quote from: gf on November 24, 2022, 08:37:05 am ---
--- Quote from: Nominal Animal on November 24, 2022, 12:42:28 am ---Small changes in DFT length \$N\$ can be confusing, because spectral leakage affects only signals whose wavelength is not an exact multiple of \$N\$.

--- End quote ---
It depends on the window function.
--- End quote ---
Yup, I agree (with your entire response).  I was only considering the window at hand.


--- Quote from: gf on November 24, 2022, 08:37:05 am ---Another point of view for leakage is that each bin's spectrum analysis filter has a particular frequency response, and all frequencies falling into the passband are accumulated by the bin.
--- End quote ---
I prefer this point of view myself.  For one, it leads to useful approaches when one is investigating single-frequency signals, and is looking for the frequency of the spectrum peaks at sub-bin precision.

(That discussion also often leads to variations of the sinc function, opening up another math avenue.)
Navigation
Message Index
Next page
Previous page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod