# 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 '20 at 19:35
• We know the frequency of the sinusoidal signal. We can see the peaks in the FFTs. We are measuring the amplitude and trying to characterize the noise. The issue is, when reporting (possibly publishing) this in a paper, we'd like to put it into some sort of standard for doing so. SNR seems to be a useful metric, but what I'm missing is if there is some kind of a standard band width, or number of FFT bins, to include when deciding what the noise level is in that SNR. Does that make sense? Sep 16 '20 at 20:14
• 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 '20 at 20:27
• The flatness of the spectrum is vastly different for different configurations of our experiment. Some of them are pretty flat except in the 1/f region. Others are quite turbulent. But that's mainly only true if you're looking at the whole spectrum. We sampled with N = 10^6, at 10x the signal frequency. So our spectra cover quite a range of frequencies. But, if you "zoom in" on the signal frequency by only looking at a certain number of bins to the left and right, the local noise is often quite flat. Sep 16 '20 at 20:49
• 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 '20 at 21:01

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).