I've tried googling and wikipedia-ing it, but I haven't gotten any answers beyond 'it's because the frequency of the input signal is sitting between two bins'.
I understand that this is the reason, but what I can't understand is why the leakage seems to extend to several adjacent bins rather than only one adjacent bin.
To illustrate what I'm talking about, here's some simulated data (code at the end of the post) :
Above is the FFT spectrum (plotted on a log scale) of a sine wave of frequency 10. The sampling rate is one, and the number of samples is 100. The graph has been FFT-shifted. There's clearly only a peak at bin 10, and the rest is on the order of numerical error, or there about.
This is the frequency spectrum at a generated frequency of 10.1. Clearly there is 'leakage' into more bins than just the immediately adjacent bin.
This is the plot for a frequency of 10.5.
Question: Why is there this leakage, and why does it extend to all the other bins, rather than the immediate adjacent bin?
Code, for anyone who's interested (Python code)
import numpy as np import matplotlib.pyplot as plt xFreq = 10.5 xSize = 100.0 xPeriod = xSize/xFreq x = np.linspace(1,xSize,xSize) data = np.sin(2*np.pi*x/xPeriod) fft = np.fft.fft(data) fft = np.fft.fftshift(fft) fig = plt.figure() ax = fig.add_subplot(111) ax.plot(abs(fft), "o") ax.set_yscale('log') plt.show()
I changed the
xFreq value from