本文介绍了Python:一维数组循环卷积的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道numpy/scipy中是否有用于1d数组圆形卷积的函数. scipy.signal.convolve()函数仅提供模式",而不是边界",而signal.convolve2d()函数需要2d数组作为输入.

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 signal.convolve2d() function needs 2d array as input.

作为时间序列作业的一部分,我需要这样做以比较开放卷积与圆形卷积.

I need to do this to compare open vs circular convolution as part of a time series homework.

推荐答案

由于这是用于家庭作业,因此我省略了一些细节.

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

如果您附加了信号 a 卷积的定义. /em>本身,则 aa b 之间的卷积将包含在 a b .

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.

例如,考虑以下事项:

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.

这篇关于Python:一维数组循环卷积的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 04:41