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

Full Spectrum:

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

Ultimately to answer your question, determine accurately what the bandwidth is of your measurement. Use that bandwidth in the analysis where you predict the total noise and you will get a useful SNR. (This makes sense, consider the result you will get from your measurement system with a noise-free signal, and then consider the result you will get with noise alone-- the ratio will be your SNR that matters as it is based on the final result-- any noise that got filtered out by your measurement system does not apply). This is analogous to a communication system where we will use the bandwidth of the signal, since the ideal receiver will have filtered out anything outside of that bandwidth but not reject any of the valuable signal. Your ideal measurement system should do the same, which means you will have interest in the spectral occupancy of your signal (and for how long it can be assumed to be stationary, which leads to concern with phase noise since that is typically not stationary... read on below).

You are likely doing an experiment where you are trying to estimate the presence of a specific signal, in the presence of noise, and ultimately will need to determine the best observation time in which to maximize your SNR (and therefore the accuracy of your estimate). Phase noise as your first measurement gave is a great indication of this as it is typically (if not always) NOT stationary over long durations, (and therefore for very long duration the typical power spectral density measurement is not valid). A much better measurement you can make that will allow you to optimize your estimation duration is the Allan Variance (also known as a two-sample Variance) since that will indicate the duration of time in which you can use an assumption of stationarity, and will then give you the averaging time that will maximize your SNR.

I go into more details of the Allan Variance and Allan Deviation for this particular application here: What determines the accuracy of the phase result in a DFT bin?

• Okay, thank you. This is helpful. I have been looking into Allan Variance for a while now, and I think we plan to get into that as our experiment progresses. But, for now we're working with SNR. Our experiment will be applicable to a wide variety of measuring devices, so the bandwidth of the measurement will vary, but I think for our immediate purposes we can focus on a specific bandwidth, at least for the SNR calculations. So, to be clear, I think you're saying that it is commonly practiced to calculate SNR for a specific band, and just make it clear in the text what that band is.. Commented Sep 17, 2020 at 2:33
• @user3308243 I believe I understand your predicament as it is related to the work I do working closely with our atomic physicist and my conclusion has been the SNR is not very meaningful without the nature of the noise —- if you can declare it to be white noise that would be sufficient and then I would just provide noise/Hz or root-Hz it magnitude quantity. Otherwise ADev would really be ideal as it would reveal the features of the noise (white, random walk etc) which will then inform the utility of the result. In any event yes you must declare what the bandwidth is when you give the SNR Commented Sep 17, 2020 at 11:26
• For short term noise that is stationary the power spectral density is fine as it similarly shows the characteristic of the noise vs bandwidth. When the noise is white the PSD reduces to one number in which case it would be valid and sufficient to just provide a single SNR/Hz value. For the other cases without seeing those plots I would struggle to get comparative value from your SNR figure unless my use was in your exact same BW Commented Sep 17, 2020 at 11:30
• Given you “know” the frequency of the signal and are characterizing it’s SNR then ADEV ans phase noise measurements are the ideal choice since that frequency is ultimately not stationary. You will also be competing with the variability of your sampling clock so you would want to have the ADEV of that as well and be sure it is much better than your device under measurement. . Commented Sep 17, 2020 at 11:34
• Is the frequency tone one that you have injected into the experiment as a reference from which to access the noise or is it an artifact of the experiment (such as a resonance) that you are measuring? If the former then it is quite likely your noise is white/stationary and a normalized result will be just fine as long as your test tone is stable enough over the duration of the test - In either case the ADEV using your measured noise would confirm this for you. Commented Sep 17, 2020 at 11:47