[SciPy-Dev] Pull Req: Add periodogram and welch functions

Eric Moore ewm@redtetrahedron....
Tue Dec 4 06:49:02 CST 2012


Jake Vanderplas wrote:
> Hi Eric,
> The contribution looks good.  Have you compared your results to those of
> matplotlib.mlab.psd()?  I believe that also implements Welch's method.
>      Jake
>
> On 12/03/2012 06:54 PM, Eric Moore wrote:
>> Hi, I've just submitted a pull request to add a function to compute a
>> simple (modified) periodogram and a periodogram using Welch's method.
>>
>> The pull request is https://github.com/scipy/scipy/pull/373
>>
>> The biggest question I have with my implementation is whether welch
>> should support padded FFTs and detrending.  But I'm happy to hear any
>> feedback.
>>
>> Eric

It does produce the same output as mlab.psd().  The functions have 
slightly different defaults.  Equivalent calls, for a sampling frequency 
of fs, a 1024 point transform, with 50% overlap, and a hanning window are

signal.welch(x, fs, nfft=1024)

vs.

mlab.psd(x, 1024, fs, noverlap=512)

I'm not sure with just having quickly looked at this what mlab.psd is 
calculating if you set scale_by_freq=False, but it doesnt match my 
scaling='spectrum'.

I've also just noticed that my code dealing with the output of rfft is 
slightly broken.  I'll push a correct version later today.

Eric





More information about the SciPy-Dev mailing list