Python: 1d array circular convolution

前端 未结 2 635
逝去的感伤
逝去的感伤 2021-01-05 13:49

I wonder if there\'s a function in numpy/scipy for 1d array circular convolution. The scipy.signal.convolve() function only provides \"mode\" but not \"boundary\", while the

2条回答
  •  南方客
    南方客 (楼主)
    2021-01-05 14:39

    Since this is for homework, I'm leaving out a few details.

    By the definition of convolution, if you append a signal a to itself, then the convolution between aa and b will contain inside the cyclic convolution of a and b.

    E.g., consider the following:

    import numpy as np
    from scipy import signal
    
    %pylab inline
    
    a = np.array([1] * 10)
    b = np.array([1] * 10)
    
    plot(signal.convolve(a, b));
    

    That is the standard convolution. Now this, however

    plot(signal.convolve(a, np.concatenate((b, b))));
    

    In this last figure, try to see where is the result of the circular convolution, and how to generalize this.

提交回复
热议问题