Fago, Matt - AES wrote:
> I suppose the issue is: what is correct? Or is it a matter of definition?
> 
> I don't have Stoica and Moses, but Bendat and Piersol eqn 11.102:
> 
>     One_Sided_PSD = 2/(n_d * N * dt) * Sum(FFT^2)
> 
> where there are n_d is the number of averages and N is the number of points 
> in the FFT.
> That seems to be scaling by the length? I'm fairly certain that the factor of 
> two (as shown
> above) is required for a one-sided PSD, as that comes from 'removing' the 
> negative
> frequency range.
> 
> Note that Matlab shows such scaling (by 2/L) even when computing the power 
> spectra directly
> from a raw (unaveraged) FFT:
> 
>    http://www.mathworks.com/support/tech-notes/1700/1702.html
>
> To me, as Matplotlib is striving to be Matlab-compatible, the default 
> behaviour should be to
> give results as close to the Matlab implementation as possible. One could 
> always have an
> option to turn off the scaling.

Yeah, scaling by a factor of two for one-sided is definitely correct now 
that I think about it.  Note, however, that the scaling by the length is 
not the problem. In fact, the current psd implementation does this 
correctly when it corrects for the power in the window.  The problem 
stems from matlab scaling by the sampling frequency.  Stoica and Moses 
don't do this, nor does Welch 1967.  I'm all for doing things in a 
Matlab-compatible way--when they're correct.  One of the reasons I 
stopped using Matlab was that it tried to be too smart for me.

> Note that the Matplotlib results also seem to have significantly less 
> frequency resolution than
> the Matlab results. Is this the case, or am I not using noffset, nfft, and 
> pad_to correctly?

It's not that you're using those incorrectly, but rather that you failed 
to notice that the default window is the Hanning window, not 
rectangular.  Try adding window=mlab.window_none to the call. (Sorry, I 
meant to mention that before in my reply.

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to