I am writing an SDR application which searches for CW signals at various predefined frequencies. Currently, the radio tunes to the appropriate LO frequency and calculates a number of FFTs to produce an averaged result, and a CFAR process searches for any signals above a given threshold. I am keen to understand the difference between this process (averaging bin magnitudes over $N$ FFTs) and simply retrieving $N$ buffers of IQ samples to calculate a larger FFT with improved resolution bandwidth. Does one method produce a better SNR than the other, and if so, why?
2 Answers
The average of multiple smaller FFT’s produces a power spectral density with less overall noise in the result, at the expense of wider resolution bandwidth. This is the Welch and Bartlett method (depending on overlap) for spectral measurement. A longer FFT will have less resolution bandwidth which is good for fine spectral resolution of closely spaced signals, but the FFT noise floor overall will have a wider distribution (more variance in its own estimate of power) so is less desirable for the measurement of signals that occupy a wider bandwidth.
The use of overlap and averaging is similar to adjusting the Video Bandwidth instead of Resolution Bandwidth on spectrum analyzers (test equipment for analog signals), for those familiar with that equipment. Adjusting Resolution Bandwidth lowers the frequency bandwidth for each measurement and thus lowers the measured noise floor; while adjusting Video Bandwidth smooths the result but does not lower the noise floor as given by the Resolution Bandwidth used.
As for which to use, if you are measuring narrow individual and stationary frequency tones, a direct FFT over the total duration along with proper windowing would be preferred to accurately estimate the power in each tone. If measuring a modulated signal with power spread over multiple bins, or noise, or both, then the Welch Method is preferred for an accurate measurement of Power Spectral Density.
As a demonstration of this I created a quick simulation using Python of Additive White Gaussian Noise (AWGN) and then took a simple FFT as shown on the left, and compared that to a spectral plot using the scipy.welch function as shown on the right. The significance is the variation of the FFT plot as given by the blue trace, where I added an orange trace showing the result average of the FFT magnitudes in dB. In comparison the Welch Method is much smoother and provides an accurate measurement of the power spectral density. What we don't see the effect of here is the significantly lower resolution bandwidth that was used to create the Welch Method plot, given the test waveform was white noise.
The waveform was created as 100,000 samples of AWGN sampled at 1 MHz with a standard deviation of $\sigma_x = 10$. The true power spectral density would be $\sigma_x^2/f_s = 100/1E6$ W/Hz, or in dBW units $10Log_{10}(1E-4)=-40$ dBW/Hz. The plot on the left is the result of an FFT on all 100,000 samples, with no additional windowing, but the FFT was scaled by the total number of samples (100,000) to normalize to the expected magnitude result. Given the 1 MHz sampling rate and 100,000 bins, the equivalent noise bandwidth (resolution bandwidth or RBW) o f each bin is 10 Hz. The average of the FFT magnitudes came to -31.03 dBW, and given the 10 Hz RBW, this would equate to -41.04 dBW/Hz. (This is consistent with the predicted -1.05 dB under-reporting error in using the average of the magnitudes to estimate power as I have detailed in this post). The result from the scipy.welch function is quite accurate with minimum noise in the result as shown in this zoomed in view below:
This was with the default configuration settings for using the Welch function, which is using a 256 sample Hann window. This particular window increases the RBW by 1.5, so the RBW that created this spectrum would have been $1.5f_s/256 = 5.86 $ KHz. The Welch function normalizes this result to be in units of dBW/Hz by reducing the result reported by $10Log{10}(5.86E3)=37.7 dB$, but this doesn't change the RBW that was actually used to create that spectrum. This means that any signal that occupies less bandwidth than 5.86KHz will also be reduced by 37.7 dB given the same settings as this test.
To show this, I repeated the experiment by adding an additional cosine tone at 100 KHz, with a peak amplitude of 1. The FFT approach has accurately presented the amplitude for the two sidebands of the cosine as each being -6 dB, while the Welch function given the adjustment mentioned above for its wider RBW has pushed those resulting tones down below the noise density of the AWGN.
Zooming in on both we see the accurate -6 dB measurement with the FFT given the 10 Hz RBW, while the Welch Method I predicted the tones to be reduced to -6 - 37.7 = -43.7 dBW. If we sum in power the -40 dBW and -43.7 dBW contributions we get: $10Log_10(10^(-40/10)+10^(-43.7/10) = -38.45 $ dBW, which is consistent with that reported by the Welch function as we see in plot below.
-
$\begingroup$ Dan, would you care to add a little mathematical explanation of why the averaging improves SNR? If not, I can do that in a separate answer ;) $\endgroup$– JdipMay 4 at 18:04
-
1$\begingroup$ @Jdip Please do! I was going to add some graphic examples but the math would be nice and welcome! $\endgroup$ May 4 at 22:59
-
-
$\begingroup$ Yes thank you @Ash! Does this existing post cover what you are referring to?: dsp.stackexchange.com/questions/67021/… $\endgroup$ May 5 at 6:44
-
1$\begingroup$ @jdip I didn’t mean for you to delete your post as I think you were on the right track. In the post that I link at the end of this post, explaining the -1.05 dB factor is a great app note by HP that details the noise process further (how the magnitudes are a Rayleigh distribution etc)… worth reading and applies to the math you seek $\endgroup$ May 9 at 22:10
NOTE
This answer has raised some concerns, might be incomplete and therefore shouldn’t be trusted as is. When I have time I’ll go back and fix what might be wrong.
ANSWER
Does one method produce a better SNR than the other, and if so, why?
While Dan answered the first part of that question, I'll try to answer the second part with semi-rigorous math, from which one can get the intuition behind SNR improvements when using frequency averaging.
The purpose of averaging data in the context of Spectral estimation is to reduce the noise variance. Recall a measure of SNR is the ratio of variances of signal and noise: $$\texttt{SNR} = \frac{var(X)}{var(N)}$$ When $N$ is AWGN, $$var(N) = \mathbb{E}\bigg[N^2\bigg] = \sigma_0^2$$ Now, when averaging $M$ segments, such that $$N_{avg} = \frac{1}{M}\sum_{k=0}^{M-1} N_k$$ we get: $$var(N_{avg}) = \mathbb{E}\bigg[N_{avg}^2\bigg] = \mathbb{E}\bigg[\left(\frac{1}{M}\sum_{k=0}^{M-1} N_k\right)^2\bigg]$$ Since the noise segments $N_k$ are independant, $\mathbb{E}\big[N_iN_j\big] = 0 \text{ for } i \neq j,$ and we can continue with: $$ = \frac{1}{M^2}\cdot\sum_{k=0}^{M-1} \mathbb{E}\bigg[ N_k^2\bigg] = \frac{1}{M^2}\cdot M\sigma_0^2 = \frac{\sigma_0^2}{M} = \frac{var(N)}{M}$$
So you see the noise variance has been reduced by a factor of $M$, which in turn increases the estimate's $\texttt{SNR}$ by a factor of $M$
-
1$\begingroup$ It would be the variance of the estimate of the variance for the AWGN that we would be concerned with, I don't think you are completely showing that here? Given AWGN only with an ENBW (as given by the number of bins) the resulting PSD will itself be a random variable with a mean (the power, or PSD if we normalize by the bandwidth) and variance (the noise of the estimate of the PSD). By reducing the number of bins, we increase the ENBW, but we also then, through averaging reduce the variance on our estimate of the PSD - which is the net result of the Welch Method. Your thoughts? $\endgroup$ May 8 at 18:57
-
1$\begingroup$ (The Welch as well as the Bartlett Method work by averaging the squared magnitudes, which if AWGN only would have a Rayleigh distribution. The mean of the Rayleigh distribution leads to the -1.05 dB error I mention in my post-- it would be the variance of this mean that we would be concerned with in the PSD result, as far as the noise we see with the straight DFT and how this is reduced by averaging the squared magnitudes) $\endgroup$ May 8 at 20:19
-
$\begingroup$ If this is about STFT, I question this math, it implies
hop_size=1
improves SNR $N$-fold. Hence also that if we double the sampling rate, we can double the SNR (by keepinghop_size=1
). $\endgroup$ May 10 at 20:44 -
1$\begingroup$ @OverLordGoldDragon this isn’t about the STFT per se, but about frequency averaging. Regardless, Dan raised a similar concern, which I actually share. I just don’t have time to go into it at the moment. $\endgroup$– JdipMay 10 at 22:00
-
$\begingroup$ Dan's answer speaks of Welch's and Barlett's methods, and of overlap? That's post-processing on STFT. Do you understand the question differently? (If so, then Dan didn't "answer the first part"?) I'm curious on noise reduction math. $\endgroup$ May 14 at 12:14