I'm trying to determine the best settings for a discrete Fourier transform on a signal with noise. Now I've stumbled on something that I can't seem to explain, I'm hoping someone can give me some insight.
My signal without noise is made of $5$ wavelengths with a frequency of $5$ MHz. Before and after the signal there is nothing. It looks like this:
When I perform a Fourier transform on it, as expected I get a peak at $5$ MHz.
Now usually my signal has lots of noise, so I want to apply a window function (rectangular) to get rid of as much noise as possible. To investigate the optimum size of my window, I've plotted the height of the peak ($5$ MHz) in the FFT against the width of the window function.
In this graph, at $x=0$ the window function has no width, so the entire signal is cut off. At $x=1000$, the window function is exactly as wide as the signal.
Now it turns out, slightly BEFORE $x=1000$ the FFT peak is actually HIGHER than at $x=1000$. Meaning that the FFT gives the highest peak when a tiny part of the signal is cut off.
Why is that?
I've tried thinking of possible reasons, but they're all completely guesswork:
Maybe it has to do with the difference between a discrete Fourier transform and a continuous Fourier transform. I could see this show up as an artifact of the quantization of the signal.
Maybe it cancels out with another property — perhaps the higher peak also becomes wider, making it blend in with noise more. If I'm only looking at my FFT at $5$ MHz however, I will still keep my advantage.
Any thoughts are appreciated!