pspectrum power spectrum or power density scaling
Show older comments
Hi everybody !
I have a matter with the pspectrum power scaling. In help documentation, it is noticed that "pspectrum scales the spectrum so that, if the frequency content of a signal falls exactly within a bin, its amplitude in that bin is the true average power of the signal".
I may have a trouble for understanding the operation underlying this explanation. I've coded periodograms computations (via |DFT|², periodogram and pwelch implementations, not indicated below) and all my results are matching with periodogram and pwelch functions results. But not with pspectrum outputs. Please find below an adapted code for testing my observation :
Ts = 0.001; % [s]
Fs = 1/Ts; % [Hz]
Duration = 5; % [s]
Ns = floor(Duration/Ts); % [-]
NoisePower = 0.5^2; % [unit²]
v_time = [0:(Ns-1)]'*Ts;
v_signal = sqrt(NoisePower)*randn(Ns,1);
energy_viatime = Ts * sum(abs(v_signal).^2);
power_viatime = energy_viatime/((Ns-1)*Ts);
% Windowing specifications
% The window used by pspectrum is a Kaiser window with BETA parameter = 40*(1-Leakage)
% where Leakage value is [0;1] (1 = rectwin)
beta = 0; leak = 1-beta/40; % here, i chose a rectwin, i.e. leak = 1
% pspectrum call
[v_PSP_2S, v_fPSP_2S] = pspectrum(v_signal,v_time, ...
'Leakage',leak,'TwoSided',true,'Reassign',false,'power');
[v_PSP_1S, v_fPSP_1S] = pspectrum(v_signal,v_time, ...
'Leakage',leak,'TwoSided',false,'Reassign',false,'power');
fprintf('Relative error of power estimation [PSP-2S]: %2.1f%%\n',abs(sum(v_PSP_2S) - power_viatime) / power_viatime * 100);
fprintf('Relative error of power estimation [PSP-1S]: %2.1f%%\n',abs(sum(v_PSP_1S) - power_viatime) / power_viatime * 100);
fprintf('\n');
% Report #1: sum(v_PSP_2S) > power_viatime && sum(v_PSP_1S) > power_viatime
% -> Power creation is impossible ! v_PSP_*S is not the expected power spectrum.
% Report #2: sum(v_PSP_1S) / sum(v_PSP_2S) ~ 2
% -> Seems to be related to the frequency interval of respective output
% Report #3: mean(diff(v_fPSP_1S)) / mean(diff(v_fPSP_2S)) ~ 0.5
% -> As a matter of fact, frequency discretization is not the same whereas sizes are equal. OK.
% -> Still a power spectrum or rather a power density ???
Can you confirm my understanding, please ?
'Input arguments' section about type as 'power' mentions the power spectrum (which is different from the PSD).
No reassignment scaling is explicitly ordered.
But here, it seems that I have a beginning of an answer (just like a clue ...)
% ... trying to implement a bandwidth scale factor ...
dF_window_enbw_2S = enbw(kaiser(size(v_PSP_2S,1),beta),Fs);
sum(v_PSP_2S)*dF_window_enbw_2S % -> may be the right one if *2. Yes, but enbw is already 2-sided.
dF_window_enbw_1S = enbw(kaiser(size(v_PSP_1S,1),beta),Fs);
sum(v_PSP_1S)*dF_window_enbw % -> may be the right one ! Yes, but enbw is 2-sided. To be single-sided ?
% => pspectrum outputs a density, not a power spectrum (in the case of white noise spectrum).
enbw documentation helps to be aware about the energy carried by each frequency bin.
There's something that I don't catch ! Several days already spent on that matter ...
Thank you for your explanation.
Answers (2)
Star Strider
on 7 Jul 2021
0 votes
5 Comments
Christophe
on 8 Jul 2021
Star Strider
on 8 Jul 2021
I cannot run that, so I cannot comment on it.
Power is generally considered to be amplitude² and I believe that is what psepectrum displays. I doubt that it is creating anything.
Christophe
on 8 Jul 2021
Star Strider
on 8 Jul 2021
My pleasure.
Paul
on 9 Jul 2021
Can you show or post a link to the definition of power spectrum?
Christophe
on 9 Jul 2021
0 votes
2 Comments
Paul
on 9 Jul 2021
Hi Christophe,
I was happy to have found this thread because, coincidentally, I've been reading about this topic on and off for the last few weeks or so (and have had that wikipedia page as an open tab for quite a while). So I don't have an opinion, just questions at that this point.
The wikipedia page seems to use the terms power spectrum and power spectral density interchangeably. Quoting from the top of the page: "More commonly used is the power spectral density (or simply power spectrum), which applies ..." So I'm still not sure if the PSD and PS are really two different things. Maybe some technical communities use the terms to mean different things and others do not?
I don't understand how Pbandlmited can be called a power spectrum. As defined, it's an integral and therefore evaluates to a number (assuming the integral exists). I don't see how it's a function of frequency as I would expect for something called a spectrum.
Jason
on 25 Dec 2024
Check this video out: https://www.mathworks.com/videos/understanding-power-spectral-density-and-the-power-spectrum-1707740400025.html
I think it explains some concepts very well!
Categories
Find more on Spectral Estimation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!