I'm attempting to understand spectral leakage and read the following quote on wikipedia:
Windowing a sinusoid causes spectral leakage, even if the sinusoid has an integer number of cycles within a rectangular window.
This confuses me, since I thought using an integral number of periods caused the leakage to disappear. Moreover, my attempts to quantify/simulate this corroborate my beliefs. For example, take the following sampled, 1Hz simple sinusoid.
import numpy as np
f = 1
ts = f / 3
fs = 1 / ts
t = np.arange(0, 5.1 * f, step=ts)
s = np.sin(2*np.pi*f*t)
with fft:
fft = np.absolute(np.fft.rfft(s))
fft /= np.sum(fft)
bins = np.fft.rfftfreq(len(t))
Now if I add an additional sample,
import numpy as np
f = 1
ts = f / 3
fs = 1 / ts
t = np.arange(0, 5.1 * f, step=ts)
s = np.sin(2*np.pi*f*t)
As expected, I get spectral leakage.
Is the Wikipedia quote incorrect, or did I misinterpret it?
Note: I think a better tag for this is spectral-leakage, but I don't have enough reputation to add it.