# How many bins to include when calculating SNR from FFT?

I'm a scientist conducting an experiment that requires some signal processing. My expertise is not in signal processing, thus here I am. We've basically re-created an experiment conducted by other scientists, attempting to check their results. Here is a link to their paper: Ultrasensitive Inverse Weak-Value Tilt Meter

In short, a laser bounces off of some mirrors, one of which is oscillating at a controlled sinusoidal frequency, onto a quadrant detector, which outputs an electrical signal to an oscilloscope where we record it. So, you end up with a noisy record that has a tiny, known sine wave hiding in it.

My question has to do with calculating the SNR from the FFTs of our records. How many bins do I include for noise? Do I include all of the non-signal bins (besides DC and Nyquist)? Or is there some standard for this type of thing?

As a follow on question, when determining the noise floor from our spectral densities, is there a certain standard calculation, or is it more of an eyeball the plot type thing? Is the floor determined for bins near the signal, or should you look at the whole record?

Thanks in advance for any help you can provide. As a side note, I have done quite a bit of due diligence trying to figure this stuff out. But, anytime I find some source that seems authoritative that says one thing, I'll find another that says something different. I can't tell if I'm misunderstanding what they're saying, or if there are just lots of different definitions for this stuff.

Here are a couple of our PSD plots.

Zoomed in on the reference signal: • +1 for due diligence. When you say tiny known signal, what is known and what do you want to measure about it? Sep 16, 2020 at 19:35
• Absolutely. Dan (and others here) are experts at proper SNR calculations, I am not. My specialty is tone parameter estimation. The one thing I can say is that you want to make sure you frame your signal on a whole number of cycles so all its "energy=sum of squares" is localized in the bin instead of "leaking". In that case your answer is one (assuming just using bins below Nyquist, half the spectrum) for your signal, and the rest are candidates for your noise. Is the spectrum relatively flat outside your peaks? Sep 16, 2020 at 20:27
• That's a big FFT. With 10 samples per cycle, you have about 100,000 cycles so framing on a whole number of cycles is going to be kind of tough unless you know the frequency very precisely. That's useful information. Have you taken any smaller DFTs on a portion of your signal? If so, are there any substantial variations in your SNR calculations? What is your SNR roughly? Sep 16, 2020 at 21:01
• Did you apply a window function? The purpose is to mitigate the "leakage" (caused by non-whole integer framing) concentrating the signal's energy near the bin. This effects how you do the SNR calculation. Sep 16, 2020 at 21:27
• Seems you've had quite the tour. Due diligence might be an understatement. My understanding (and again SNR analysis can be complicated and I am not versed), is that if you have a single pure tone, you should be able calculate its signal strength exactly (given exact parameters, theoretically ideal), then subtract the tone from the signal and measure the residual. This approach sort of presupposes very short intervals and a subsequent aggregation. The assumption that a real world sign is a pure tone for too long doesn't usually last. I tend to work in frames with single digit cycle counts. Sep 17, 2020 at 2:36

The OP's question requires further details to provide a definitive answer, but the following will give the considerations involved. If the noise is white and stationary then the answer is clear in that we can simply use a power spectral density and work with the SNR as an SNR/Hz quantity. If the noise is not white (meaning the average power across all bins is not the same) then the concern will ultimately be with the measurement bandwidth of your final system that is providing the estimate of the quantity you are looking for. You would include all noise that is within this bandwidth as that is what will give you the statistical error in your result (which is why we are concerned with SNR in the first place). Usually the choice of bandwidth comes down to a time /frequency decision and the coherence time of your signal, and for how long it can be assumed to be stationary. For bandwidth limited signals that can be assumed to be stationary for a long time, then we can use a relatively longer averaging time (reducing the bandwidth down to that of the signal, and therefore the amount of total noise in our result, as long as the noise is a spectral density and not a "spur" that exists at one frequency).