Skip to content

Are odd-length window functions supposed to be always symmetrical? (Trac #1665) #2190

@scipy-gitbot

Description

@scipy-gitbot

Original ticket http://projects.scipy.org/scipy/ticket/1665 on 2012-05-30 by @endolith, assigned to @cournape.

The window functions in scipy.signal have a sym option for producing symmetric windows or periodic windows, but if you create a periodic window of an odd size, it gives identical output to a symmetric window. This is in the code, but is it right? It doesn't match Matlab's behavior, as described [https://ccrma.stanford.edu/~jos/sasp/Matlab_Hamming_Window.html here].

If it's right, it should be documented why it works this way

>> hamming(3) % same in Matlab and Octave
ans =
    0.0800
    1.0000
    0.0800
>> hamming(3,'symmetric') % Matlab only
ans =
    0.0800
    1.0000
    0.0800
>> hamming(3,'periodic') % Matlab only
ans =
    0.0800
    0.7700
    0.7700
>> hamming(4) % same in Matlab and Octave
ans =
    0.0800
    0.7700
    0.7700
    0.0800

SciPy:

In [2]: hamming(3)
Out[2]: array([ 0.08,  1.  ,  0.08])

In [3]: hamming(3,sym=True)
Out[3]: array([ 0.08,  1.  ,  0.08])

In [4]: hamming(3,sym=False)
Out[4]: array([ 0.08,  1.  ,  0.08])

In [5]: hamming(4)
Out[5]: array([ 0.08,  0.77,  0.77,  0.08])

In [6]: hamming(4, sym=True)
Out[6]: array([ 0.08,  0.77,  0.77,  0.08])

In [7]: hamming(4, sym=False)
Out[7]: array([ 0.08,  0.54,  1.  ,  0.54])

Metadata

Metadata

Assignees

No one assigned

    Labels

    Migrated from TracdefectA clear bug or issue that prevents SciPy from being installed or used as expectedscipy.signal

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions