Why FFT signal power is 3dB higher than definition

It seems the signal power is 3dB higher than actual power. Does anyone can explain me why?
For example, I have f(t)=A*sin(2*pi*f*t), its power is f(t)^2 integrated over a cycle then divide the cycle period, (1/T*int(f(t)^2)) which is equal to A^2/2 as expected. (match with RMS calculation as well =(A/sqrt(2))^2)
However, both Cadence Virtuoso dft and Matlab FFT give me signal power = A^2.
The way how I calculate the power is as below: I assume the amplitude of the single tone in one bin of FFT results (coherent sampling) is magx. I calculate the power as magx^2.
I have to calculate the power in this way instead of (magx/sqrt(2))^2 because the noise from all other bins are calculated as sum squared. Otherwise, my SNR will be wrong.
From another perspective, it means the noise is also 3dB higher than actual gaussion noise variance value. So the final SNR is correct if I calculate the signal power as magx^2, which is 3dB higher than actual signal power.
I just wonder why there is 3dB difference in fft results compared with actual power, especially for noise? It seems to me the FFT report peak magnitude instead of rms magnitude.
I have the code attached.
%%whether fft give noise in rms or peak, what is the correct snr?
%%SNR/FFT/SFDR/SNDR/noise simulation
%%https://www.mathworks.com/help/signal/ref/snr.html#bt3er4n
%%https://www.mathworks.com/help/matlab/ref/fft.html
clear;close all;
rng default
%rng(1);
FlagTwoTone = false;
tone1 = 53/128*800e6;
Amp = 0.532 * 10^(1.37/20); %input amplitude * PGA gain = 0.623
fs = 800e6;
N = 128;
t = (0:N-1)*1/fs;
freq = fs*(0:(N/2))/N;
noisestd = 300e-6; % assume noise std = 300 uV
sig = Amp*sin(2*pi*tone1*t);
noise = noisestd*randn(size(sig)); %zero mean, variance = noisestd^2
myx = sig + noise;
Tone1dB = 20*log10(Amp/sqrt(2))
noisedB = 20*log10(noisestd)
%deltadB= Tone1dB - noisedB
mySNRviasnr = snr(sig, noise)
Y = fft(myx, N); %length(myx) = N
P2 = abs(Y/N); %double sided fft spectrum, convert complex to mag and then divided by N=128, why divide 128?
P1 = P2(1:N/2+1); %matlab starts with 1
P1(2:end-1) = 2*P1(2:end-1);
modP1 = P1;
figure(1);
plot(freq,P1)
title('Single-Sided Amplitude Spectrum of myx(t)')
xlabel('f (Hz)')
ylabel('|P1(f)|')
grid on;
simTone1amp = 0;
simTone1index = 0;
simTone1freq = 0;
for i = 1:length(modP1)
if simTone1amp < modP1(i)
simTone1amp = modP1(i);
simTone1index = i;
end
end
%simTone1index
%simTone1amp =P1(simTone1index)
simTone1freq = freq(simTone1index);
modP1(simTone1index) = 0;
simTone1dB = 20*log10(simTone1amp)
if FlagTwoTone %two tones only
simTone2amp = 0;
simTone2index = 0;
simTone2freq = 0;
for i = 1:length(modP1)
if simTone2amp < modP1(i)
simTone2amp = modP1(i);
simTone2index = i;
end
end
simTone2freq = freq(simTone2index);
modP1(simTone2index) = 0;
end
simHarmonicAmp = 0;
simHarmonicIndex = 0;
simHarmonicFreq = 0;
%test = 0;
for i = 1:length(modP1)
%test = test + modP1(i)^2;
if simHarmonicAmp < modP1(i)
simHarmonicAmp = modP1(i);
simHarmonicIndex = i;
end
end
simHarmonicFreq = freq(simHarmonicIndex);
fftTotalNoise = sum(modP1.^2);%sum squared total noises
simNoisedB = 10*log10(fftTotalNoise)
%test
if FlagTwoTone
else
SNDR = 10*log10(simTone1amp^2/fftTotalNoise)
end

 Akzeptierte Antwort

dpb
dpb am 19 Mai 2018
Bearbeitet: dpb am 19 Mai 2018
The normalization is all in your code--
P2 = abs(Y/N);
P1 = P2(1:N/2+1);
P1(2:end-1) = 2*P1(2:end-1);
This is the way to normalize a one-sided PSD such that the peak amplitude for a pure signal matches the peak of the signal in time domain; if you want RMS, then that's up to you.
NB: However, this normalization for a single bin works(*) only if the frequency sampling is such the tone of the input signal exactly matches a frequency bin; otherwise the energy will be spread over adjacent bins...discussion/illustration just a few days ago at Answer_319928
(*) That is, the normalization is correct; the maximum amplitude of a single bin in the PSD only matches the time domain peak if the energy is all at the precise bin frequency.

6 Kommentare

CreativeLet
CreativeLet am 19 Mai 2018
Bearbeitet: CreativeLet am 21 Mai 2018
Why the normalized energy is 3dB higher than actual power? If it's right, then the DFT power should be equal to actual power. It's not up to me to divide by N or N*sqrt(2). What's the physical meaning to divide by N? Isn't divide by N*sqrt(2) a weird number?
I have controlled the signal to be located exactly in one bin (coherent sampling). The link seems not exactly related to my question.
I will appreciate if you can provide me insights into this question.
dpb
dpb am 19 Mai 2018
Bearbeitet: dpb am 20 Mai 2018
Beg to differ; the link (and the earlier to which there's a link there) are directly tied into the question.
Yes, it is up to you to divide by N; the factor of 2 depends on how you want to treat the double-sided result which is returned wherein half the power is in the negative frequency, the other half in the positive (and, of course, there's the fact that there's only one DC bin and one Fmax bin). See if the discussion at the following link might help on why can get differing results depending: FFT Normalisation
If you sample at such a frequency a noise-free signal is precisely centered on a frequency bin, then the shown normalization will identically produce the peak amplitude of the signal in the time domain. If you prefer to normalize so the peak amplitude in PSD matches the RMS of the time domain signal, then you must use the sqrt(2) factor as well.
Reverting to the prior example where S is the two-component sine wave of 0.7/1.0 magnitude at 50/120 Hz, respectively, then to illustrate Parseval's theorem holds in Matlab:
>> sum(S.*S) % sum signal^2 in time domain
ans =
1117.5
>> Y=fft(S); % DFT of S
>> sum(abs(Y).^2) % sum abs of FFT is big number
ans =
1676250
>> ans/L % divide by N and Voila!!!
ans =
1117.5
>>
So there is where the N comes from and its meaning; it's the normalization factor in Parseval's theorem as Star Rider pointed out in the answer to one of the links you pointed to.
The links illustrate conclusively that the above normalization returns 0.7 and 1.0 for the two magnitudes; dividing by an addtional SQRT(2) will return RMS for the two as well...
>> S120 = sin(2*pi*120*t); % the 120 Hz component
>> rms(S120)
ans =
0.7071
>> S50 = 0.7*sin(2*pi*50*t); % and the 50 Hz one
>> rms(S50)
ans =
0.4950
>> P1=P1/sqrt(2); % normalize to RMS from peak amplitude
>> [pk,loc]=findpeaks(P1,f,'NPeaks',2,'MinPeakHeight',0.25) % return peak, location
pk =
0.4950 0.7071
loc =
50 120
>>
CreativeLet
CreativeLet am 21 Mai 2018
Bearbeitet: CreativeLet am 21 Mai 2018
Thanks for the link of FFT normalization. It helps a lot. I think my expression might confuse you. I am now clear with FFT without doubts. The problem might be more on the definition of power. Here is my explanation.
In my example, I have single tone sinusoidal signal and within the 160ns plotting range, there are exactly 53 whole cycles, so based on the power definition of total energy over the time, I will get the power equal to rms^2 (integrate the waveform squared then over time), which is (0.623/sqrt(2))^2. Or rms(S120)^2 in your case.
However, the definition of power for FFT treat time domain signal power as mag^2, which is what you calculated as sum(S.*S).
Hence, these two definitions will result in different power, which is 3dB difference.
Let me know if you have another explanation.
dpb
dpb am 22 Mai 2018
Bearbeitet: dpb am 25 Mai 2018
I think the explanation is as given; there are many possible choices for normalization; use the one that makes sense for your application. As the link discusses, many commercial instruments use a particular form; that they're packaged and "what you see is what you get" may make one believe that's the way it's got to be, but inside those instruments' firmware are the same decisions and operations; just that they chose a specific set.
With Matlab, TMW supplies the raw tool of the DFT and leaves it to the user to determine how to interpret the result.
ADDENDUM While it's been a while and may not return, I'll just add re: your comment re: "FFT time domain signal power" that as illustrated, Parseval's theorem of equal power in time and frequency domains is that
SUM(S^2) = 1/N SUM(Y(S)^2))
or the total power is integral of magnitude in BOTH domains; you've introduced the RMS() into the time domain in the comparison above without doing the compensating equivalent in the frequency domain. To maintain the equality you have to make the same assumptions in each domain.
CreativeLet
CreativeLet am 25 Mai 2018
Bearbeitet: CreativeLet am 25 Mai 2018
I am not introducing RMS(), it's just total power over time (definition of Power) is equivalent to the square of RMS(magnitude).
the SUM(S^2) as Parseval's theorem defines is not the actual power. Even in electrical engineering, people calculate power as SUM(V^2/R). The 1/R is missing from the Parseval's theorem or the general definition of FFT results in Matlab. (see page here for electrical power definition)
From that perspective, SUM(S^2) is a scaled version of power, definitely not the actual power you can measure with an instrument.
It reminds me of physical instrument that can do FFT analysis like oscilloscope/spectrum analyzer. I believe their algorithm will use the below equivalent derived from Parseval's theorem.
SUM(S^2/2) = 1/N * SUM(Y(S)^2/2)
Otherwise, Their FFT/DFT results won't match with time domain power measurement, there will be 3dB difference.
dpb
dpb am 25 Mai 2018
Misunderstood what I was driving at I think; the FFT doesn't know or care about what the input is; which is why there's no 1/R term in the ML version. The instruments are developed "for purpose".
That there needs be a RMS() term for your purpose I'm not disagreeing.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Jesús Lucio
Jesús Lucio am 14 Sep. 2020

0 Stimmen

Hi (2 years late, I know!, but the topic is interesting forever, isn't it?)
Note that 3dB approximately equals 10log10(2), so in "normal" (not dB) units, we are talking of just a factor 2 (instead of a term 3dB). I'm pretty sure it's because actual power is that of two peaks (as the signal is real, then the FFT is symmetric) and possibly you are considering only one (for positive frequencies typically) peak. Can it be that?

1 Kommentar

CreativeLet
CreativeLet am 1 Mär. 2021
Bearbeitet: CreativeLet am 1 Mär. 2021
that's 6dB difference by your description, 20*log10(2), do you read my code?

Melden Sie sich an, um zu kommentieren.

Tags

Gefragt:

am 18 Mai 2018

Bearbeitet:

am 1 Mär. 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by