# Is spectral leakage normal for FFT?

I record a sample of 2000 data points, with a sampling rate of 40khz, so freq. resolution is 20hz. I multiplied the chunk of data with a Hanning window prior to doing the FFT.

I recorded a 1khz test tone, and the result of FFT showed a peak at 1khz, as it should. But the magnitudes at 980hz and 1020hz is also significantly higher than the rest, although not as high as the magnitude at 1khz (about 50%).

Is this really bad? Did I apply the Hanning window wrong or is this unavoidable? Will using finer frequency resolution help?

• for any frequency component having frequency that is not exactly an integer times 20 Hz, there will be spectral leakage apparent. now 1 kHz is 50 times 20 Hz, so are you sure the frequency your 1 kHz tone was precise? – robert bristow-johnson Aug 13 '19 at 2:25
• It's ok. If you used an FFT length of 2000 points, then only the bins at 980 Hz and 1020 Hz (and mirrors) should show up and all the rest be zero. For other FFT lengths you will see more nonzero components... – Fat32 Aug 13 '19 at 2:44
• I played a 1khz tone from Youtube, so it might not be a precise signal I guess – user173729 Aug 13 '19 at 13:31

• //"If the data that is feed to an FFT is not exactly integer periodic in the FFT’s length, then there will always be windowing artifacts"// - - - yes, and the true source of these artifacts is not in the FFT (or DFT) but is in the action of yanking $N$ samples from a stream of data. the DFT will always simply assume that the $N$ samples passed to it are one cycle of a periodic waveform having period of exactly $N$ samples. – robert bristow-johnson Aug 13 '19 at 20:21
• i know hot, but the basis functions are all periodic with period $N$. whether you approve of my anthropomorphizing an algorithm or not, the FFT is an efficient DFT. the DFT and the Discrete Fourier Series are one-and-the-same. the DFT takes the $N$ samples passed to it as a complete definition of a periodic sequence having period length of $N$ and bijectively maps it to another periodic sequence also having period length of $N$. that is what the DFT does. – robert bristow-johnson Aug 13 '19 at 22:37
• no hot, they are precisely the same thing. except, in O&S, one uses $x[n]$ and $X[k]$ for notation and requires modulo arithmetic in the indices (which explicitly periodically extends the finite sequence) and the other uses $\tilde{x}[n]$ and $\tilde{X}[k]$ for notation and requires no modulo arithmetic in the indexing because the periodicity is understood: $\tilde{x}[n+N]=\tilde{x}[n]\ \forall n \in \mathbb{Z}$ and similarly for $\tilde{X}[k]$. but the math is identical for both. – robert bristow-johnson Aug 14 '19 at 0:21