# Are there any difference between the FFT magnitude of a signal and average FFT magnitudes of the signal broken into multiple frames?

Suppose I calculate the FFT of a 5 seconds sound wave. If I'm only interested in the FFT magnitudes across frequencies, I should obtain the same result if I segmented the sound wave into five 1-second frames, obtain the FFT magnitude for each, and taking the average of the magnitude across the frequencies?

Calculating the FFT across a longer signal would allows for smaller frequency resolution, assuming sampling rate is constant.

Does averaging across the frames offer advantages in reducing white noise in the signal? Or does it not matter in that one would get the same result with a long FFT? When might one uses the average magnitudes across frames?

Thanks

• you will get similar magnitudes but not the same because the FFT lengths will most likely be different for the 2 scenarios you mentioned. Calculating the FFT across a longer signal (provided that you use a longer FFT length) will actually result in higher frequency resolution (yes, the frequency/bin bandwidth is narrower/smaller) Apr 29 '20 at 18:00

You would consider sectioning the overall data into smaller FFT frames for the possible reasons:

• you are interested to know that for certain durations of time (length of ye FFT sections) which frequencies were active

• there are not enough hardware cycles or resources to carry out a bigger FFT

If you are only interested in knowing what frquencies were ever present in the signal in it's entire duration and you have computation resources to carry out bigger FFTs then yes, you can carry out the FFT of the entire signal itslef. The bigger the sample size of signal duration in time domain over which the FFT is taken the better the resolution in frequency.

For the case you mention you would need to average out by 5 the result of the bigger FFT

Sectioning the Data and Averaging Magnitudes Will Not Improve the Noise

The degradation in the noise floor over that achieved by just taking a DFT of the entire sequence will be:

$$nf\Delta = 10Log_{10}(M) \text{ dB}$$

Where $$M$$ is the number of partitions, and $$nf\Delta$$ is the increase in the noise per bin over taking the longer DFT. This is the same mean noise level as the DFT of just one partition. Further averaging with the magnitudes from other partitions will only smooth the noise but will not reduce the mean level.

In the OP's example, this is with $$M = 5$$ resulting in a noise floor degradation of $$7$$ dB over that achieved with a DFT of the entire sequence with no further improvement through further averaging. This is explained in more detail below as well as confirmed through simulation with the following result for two cases, case 1 with the DFT of the entire sequence vs case 2 with partitioning and averaging per the OP. The Case 2 results are no different than a single DFT of the shorter sequence:

Case 1 SNR Predicted: 55.03 dB
Case 1 SNR Actual: 55.02 dB
Case 2 SNR Predicted: 48.04 dB
Case 2 SNR Actual: 48.00 dB


Further, for any length sequence, the measurement of the noise floor using the mean of the DFT magnitudes given by a complex zero-mean AWGN noise process underestimates the noise per bin by $$-1.05$$ dB. In this case since we are interested in the noise of the magnitudes specifically, the noise of the magnitudes will be $$1.05$$ dB better than the noise of the underlying zero-mean AWGN process. This is from taking the magnitude of any DFT noise floor and not specific to further averaging those samples.

To optimize the reduction of white noise, all samples should be summed prior to computing any magnitudes. This optimizes the processing gain (signal to noise ratio in each bin). For coherent samples with additive white noise added (coherent meaning all samples contributing to a particular bin in the DFT result, referred to as the signal in signal-noise), processing gain occurs when you sum over the samples since the magnitude of the signal that is coherent will go up by $$N$$ while the magnitude of the noise (standard deviation) will only go up by $$N$$, resulting in a processing gain of $$10Log_{10}(N)$$ dB. Thus the longer length DFT provides the best processing gain, and therefore the lowest DFT Noise floor. Any other approach with taking the magnitudes of smaller blocks and averaging them will not have this processing gain, and will have a higher DFT noise floor relative to the signal. For those familiar with spectrum analyzers, this is equivalent to adjusting the video bandwidth (VBW) instead of resolution bandwidth (RBW): If you adjust VBW, the noise floor is smoothed but does not go down, while adjusting the RBW causes the average level of the noise to go down relative to the signal. Also, as explained in more detail at the end, it would not be acceptable to simply add the samples from each partition prior to taking the magnitude.

If only $$M$$ DFT bins are needed for frequency resolution but $$N$$ samples are available, other solutions for minimizing noise per bin would be to do a 5 point moving average in the time domain and then downsample prior to taking the DFT if a lower sampling rate was acceptable, OR do a 5 point moving average on the frequency result of the N point DFT (prior to taking a magnitude) if instead a lower frequency resolution was acceptable.

I compare the SNR performance of the two cases (one long N point DFT vs partitioning and adding the magnitudes) using samples of constant magnitude $$A$$ with additive complex zero-mean Gaussian white noise ($$g_n$$). The square term is ultimately used to compare based on power quantities.

The samples are given as $$x_n$$:

$$x_n = Ae^{j\omega_o n} + g_n$$

Where $$g_n \sim \mathcal{CN}(0,\sigma)$$: a zero mean complex AWGN process with standard deviation = $$\sigma$$

Case 1: Magnitude Squared of the Correlation $$|\sum (x_n e^{-j\omega_o n})|^2$$

This is the magnitude squared for each bin of the DFT result and shows the comparative SNR in each bin if we were to take a DFT of the entire sequence (no partitioning), or the SNR for a smaller sequence to be then used in Case 2. In contrast to Case 2, this result applies if we consider the SNR of a single bin with signal and noise components or comparing two bins, one with signal >> noise, and another that has noise only.

$$y[n] = |x_1 e^{-j\omega_o} + x_2 e^{-2j\omega_o} + \ldots + x_Ne^{-Nj\omega_o}|^2$$

$$= |(A+g_1e^{-j\omega_o}) + (A+g_2e^{-2j\omega_o}) + \ldots + (A+g_Ne^{-Nj\omega_o})|^2$$

$$= |NA + (g_1e^{-j\omega_o}+ g_2e^{-j\omega_o}+\ldots + g_Ne^{-Nj\omega_o})|^2$$

First consider the SNR of the summation prior to taking the magnitude, which represents one bin of the DFT output:

Signal Power = $$(NA)^2$$

Noise Power: Since $$g_n$$ is white, then all samples of $$g_n$$ are independent and therefore the phase rotations do not impact the variance. The variance of the sum of $$N$$ independent noise samples increase by $$N$$ to be

Noise Power = $$N\sigma^2$$.

However for the case of the SNR of the magnitude of each bin, we will get different results when comparing a bin that has both signal and noise with a high SNR, to a bin with noise alone. This is because the magnitude of a non-zero mean complex Gaussian variable (what happens when A is added) is Ricean distributed, while the magnitude of a zero-mean complex Gaussian variable (noise alone) is Rayleigh distributed. For large $$A/g_n$$ ratios the Ricean distribution approaches a non-zero mean Gaussian distribution with standard deviation $$\sigma$$ and then in this case the standard deviation of the summation goes up by a factor of $$\sqrt{N}$$ as already introduced. However for low $$A/g_n$$ ratios, the magnitude approaches that of a Rayleigh distribution. The mean of a Rayleigh distribution is $$\left(\sqrt{\pi/4}\right)\sigma$$, which if further summed after taking the magnitude (as in case 2) would be accumulated in summation, increasing the noise standard deviation by a factor of $$M\sqrt{\pi/4}$$, where $$M$$ is the number of times summed, or if averaged over $$M$$ samples would be scaled $$\sqrt{\pi/4}$$.

Thus the noise of the magnitude for high SNR is:

Noise Power =$$N\sigma^2$$

And for bins with noise only (no signal):

Noise Power =$$\frac{\pi}{4} N\sigma^2$$

SNR for Case 1:

With $$A >> \sigma$$:

$$\text{SNR} = (NA)^2/(N\sigma^2) = N\frac{A^2}{\sigma^2}\tag{1}\label{1}$$

With $$A \approx \sigma$$:

$$\text{SNR} \approx (NA)^2/\left(\frac{\pi}{4} N\sigma^2\right) = N\frac{4}{\pi}\frac{A^2}{\sigma^2}\tag{2}\label{2}$$

Case 2: Square of sum of the magnitudes $$(\sum|x_n|)^2$$

This is representative of the OP's suggestion, where the magnitude of each DFT result for each subframe is averaged, such that $$|x_n|$$ represents the magnitude of each of the smaller 5 DFTs (here generically given as M frames). And to compare in units of power, the square of this result would be given as:

$$y[n] = (|x_1| + |x_2| + \ldots + |x_M|)^2$$

$$y[n] = \left(|(Ae^{j\omega_o} + g_1)| +|(Ae^{j2\omega_o}+ g_2)| + \ldots +|(Ae^{j3\omega_o n)} + g_M|\right)^2$$

Since $$=0, n \ne m$$ this is also equivalent to the sum of the square of the magnitudes $$\sum|x_n|^2$$:

$$y[n] = (|x_1|^2 + |x_2|^2 + \ldots + |x_M|^2)$$

For high SNR, $$A >> g_n$$ this is:

$$y[n] = (|A +g_1| +|A +g_2| + \ldots +|A +g_M|)^2$$

Signal Power: $$(MA)^2$$

Noise Power (if no signal): $$\left(\frac{\pi}{4}\right)(M\sigma)^2$$

Noise Power (if signal >> noise): $$M \sigma^2$$

SNR for Case 2:

With $$A >> \sigma$$:

$$\text{SNR} = (MA)^2/(M\sigma^2) = M\frac{A^2}{\sigma^2}\tag{3}\label{3}$$

With $$A \approx \sigma$$:

$$\text{SNR} \approx (MA)^2/\left(\frac{\pi}{4}M^2\sigma^2\right) = \frac{4}{\pi}\frac{A^2}{\sigma^2}\tag{4}\label{4}$$

What this means

If the noise in otherwise unpopulated bins is of concern (this is the DFT noise floor and sets the achievable sensitivity for weaker signals), the SNR will be as given by $$\ref{4}$$, but if the noise is specific to the shared spectrum of a waveform that has a sufficiently high SNR, then the higher SNR result of $$\ref{3]$$ will be achieved, which is equivalent to Case 1. However, if the SNR per bin is already high, then there may not be a reason for further processing to reduced noise.

So what this shows specific to the OP, we see by comparing $$\ref{2}$$ and $$\ref{4}$$ that there is no advantage to further processing five N/5 length DFT's as far as reducing the DFT noise floor. This will however according to $$\ref{3}$$ increase the SNR for signal and noise that occupy the same spectral bins, but only to the point of restoring what could have been achieved in the one longer N-point DFT.

Confirmation

The results were posted at the top of this response and the MATLAB/Octave script is given below:

N = 10000;                 # number of total samples
M = 5;                    # number of partitions
sigma = 2;                # standard deviation for added complex
A = 10;                   # Amplitude for signal
sig = A*ones(N, 1);       # keep signal in one bin (DC)
noise = sigma/sqrt(2)*randn (N,1)+j*sigma/sqrt(2)*randn(N,1); #AWGN
x = sig+noise;

# Case 1: One N lengthFFT
y = fft(x);
sigout1 = abs(y(1));             # signal result
noiseout1 = mean(abs(y(2:end))); # noise result

predict_case1 = 10*log10(N*A^2./sigma.^2)- 10*log10(pi/4);
actual_case1 = 20*log10(sigout1/noiseout1);

# Case 2 Partition and add magnitudes
x2 = reshape(x,N/M, M);    # reshape to N/M rows, M columns
y2 = fft(x2);              # fft of each column
ysum = sum(abs(y2)');      # sum magnitudes of each fft bin

sigout2 = abs(ysum(1));    # signal result
noiseout2 = mean(abs(ysum(2:end)));   # noise result

predict_case2 = 10*log10(N*A^2./sigma.^2)- 10*log10(M*pi/4);
actual_case2 = 20*log10(sigout2/noiseout2);

printf("Case 1 SNR Predicted: %0.2f dB\n", predict_case1);
printf("Case 1 SNR Actual: %0.2f dB\n", actual_case1);
printf("Case 2 SNR Predicted: %0.2f dB\n", predict_case2);
printf("Case 2 SNR Actual: %0.2f dB\n", actual_case2); Also if a partitioning approach must be used, and the moving average approaches already suggested are not feasible, then it is VERY important that the magnitudes of each bin are computed prior to the summation in the average. It may be tempting from the summary above to consider summing samples of each DFT prior to computing the magnitudes and possibly achieve the higher processing gain noted. However, if you sum the actual samples, the resulting $$N/5$$ frequency bins will be identical to every 5th sample in the DFT of $$x[n]$$. (Assuming $$N/5$$ is an integer). Any other information in the other frequency bins will be completely lost with such an approach! For example, you could have a result for the complete DFT of $$x[n]$$ such that every 5th bin of $$X[k]$$ is zero, while all the other bins are non-zero. The $$N/5$$ samples of doing the process above of averaging the 5 DFT frames will result in all zeros!

Also we see that summing the magnitudes of the partitions only achieves an SNR improvement in the samples that already have high SNR, while there is no change in the SNR for all the other samples compared to a single DFT of just one of the partitions.