简体   繁体   English

numpy.convolve 如何完成它的工作?

[英]how dose numpy.convolve do its job?

thanks to this link enter link description here , I've got a sense about numpy.correlate function.多亏了这个链接,在这里输入链接描述,我对 numpy.correlate 函数有了一些了解。

[3 4]
[1 1 5 5]
= 3 * 1 + 4 * 1 = 7
  [3 4]
[1 1 5 5]
= 3 * 1 + 4 * 5 = 23
    [3 4]
[1 1 5 5]
= 3 * 5 + 4 * 5 = 35

my question is, how dose numpy.convolve do its job, which gives this result?我的问题是,numpy.convolve 如何完成它的工作,这给出了这个结果?

>>>np.convolve(W,X,'valid')
array([ 7, 19, 35])

how does numpy get the value 19 in the middle? numpy 如何在中间得到值 19?

thanks in advance!提前致谢!

Per your link:根据您的链接:

The convolution of two signals is defined as the integral of the first signal, reversed , sweeping over ("convolved onto") the second signal and multiplied (with the scalar product) at each position of overlapping vectors.两个信号的卷积被定义为第一个信号的积分,反转,扫描(“卷积到”)第二个信号并在重叠向量的每个位置相乘(与标量积)。

You missed the bolded part.你错过了粗体部分。 So what happens is actually this:那么实际发生的事情是这样的:

np.convolve([3, 4], [1, 1, 5, 5], 'valid')

4 * 1 + 3 * 1 = 7
4 * 1 + 3 * 5 = 19
4 * 5 + 3 * 5 = 35

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM