卷积函数:

numpy.convolve(avmode='full')

Parameters:

a : (N,) array_like

First one-dimensional input array.

v : (M,) array_like

Second one-dimensional input array.

mode : {‘full’, ‘valid’, ‘same’}, optional

‘full’:

By default, mode is ‘full’. This returns the convolution at each point of overlap, with an output shape of (N+M-1,). At the end-points of the convolution, the signals do not overlap completely, and boundary effects may be seen.

‘same’:

Mode ‘same’ returns output of length max(M, N). Boundary effects are still visible.

‘valid’:

Mode ‘valid’ returns output of length max(M, N) - min(M, N) + 1. The convolution product is only given for points where the signals overlap completely. Values outside the signal boundary have no effect.

Returns:

out : ndarray

Discrete, linear convolution of a and v.

The discrete convolution operation is defined as

It can be shown that a convolution  in time/space is equivalent to the multiplication in the Fourier domain, after appropriate padding (padding is necessary to prevent circular convolution). Since multiplication is more efficient (faster) than convolution, the function scipy.signal.fftconvolveexploits the FFT to calculate the convolution of large data-sets.

Note how the convolution operator flips the second array before “sliding” the two across one another:

>>>

>>> np.convolve([1, 2, 3], [0, 1, 0.5])
array([ 0. , 1. , 2.5, 4. , 1.5])

Only return the middle values of the convolution. Contains boundary effects, where zeros are taken into account:

>>>

>>> np.convolve([1,2,3],[0,1,0.5], 'same')
array([ 1. , 2.5, 4. ])

The two arrays are of the same length, so there is only one position where they completely overlap:

>>>

>>> np.convolve([1,2,3],[0,1,0.5], 'valid')
array([ 2.5])

numpy.convolve()的更多相关文章

  1. numpy.convolve函数用法

    函数numpy.convolve(a, v, mode=‘full’),这是numpy函数中的卷积函数库 参数: a:(N,)输入的一维数组 b:(M,)输入的第二个一维数组 mode:{‘full’ ...

  2. [开发技巧]·Python极简实现滑动平均滤波(基于Numpy.convolve)

    [开发技巧]·Python极简实现滑动平均滤波(基于Numpy.convolve) ​ 1.滑动平均概念 滑动平均滤波法(又称递推平均滤波法),时把连续取N个采样值看成一个队列 ,队列的长度固定为N ...

  3. numpy中的convolve的理解

    https://blog.csdn.net/u011599639/article/details/76254442 函数 numpy.convolve(a, v, mode=‘full’),这是num ...

  4. numpy&pandas基础

    numpy基础 import numpy as np 定义array In [156]: np.ones(3) Out[156]: array([1., 1., 1.]) In [157]: np.o ...

  5. Convolution卷积算法python以numpy,Matplotlib实现

    1:简述 Numpy拥有函数numpy.convolve(a, v, mode='full')[source]¶,通过该函数完成卷积算法并图形化(Matplotlib)实现. 2:卷积定理 原理: 设 ...

  6. 互相关(cross-correlation)及其在Python中的实现

    互相关(cross-correlation)及其在Python中的实现 在这里我想探讨一下“互相关”中的一些概念.正如卷积有线性卷积(linear convolution)和循环卷积(circular ...

  7. Moving Average

    移动平均算法Demo #!/usr/bin/python2.7 # Fetch data from BD and analyse. import json import urllib import t ...

  8. 相关与卷积(数字信号处理)的数学原理及 Python 实现

    数学原理 在数字信号处理中,相关(correlation)可以分为互相关(cross correlation)和自相关(auto-correlation). 互相关是两个数字序列之间的运算:自相关是单 ...

  9. python3绘图示例3(基于matplotlib:折线图等)

    #!/usr/bin/env python# -*- coding:utf-8 -*-from pylab import *from numpy import *import numpy # 数据点图 ...

随机推荐

  1. JS中的定时器

    在JS中的定时器分两种: 1,setTimeout() 2,setInterval() setTimeout(): 只在指定时间后执行一次: function hello(){ alert('hell ...

  2. 将自己数据转化为cifar10支持的lmdb

    大家都知道,在caffe里面,要运行cifar10的例子就得先由cifar10的数据库.由于caffe为了提高运行效率,减少磁盘寻道时间等,统一了数据接口(lmdb,leveldb). 首先,看一下c ...

  3. 恒大威武!关于SQL的一些基础知识整理回顾

    首先的首先,恒大威武! 开始正题. 关系代数: 目前主流的关系型数据库,是建立在关系代数的基础上的,即他的数学支撑是关系代数. 关系代数主要包括如下几个二目运算:并运算union.交运算interse ...

  4. [z]单次遍历带权随机选取

    http://www.gocalf.com/blog/weighted-random-selection.html 没事可以看看,这个博客里面很多文章不错

  5. leetcode278

    /* The isBadVersion API is defined in the parent class VersionControl. bool IsBadVersion(int version ...

  6. 【304】python专题-读取xml文件

    参考:XML DOM 参考手册(w3school) 参考:python专题-读取xml文件 参考:请问用python怎么修改xml的节点值? 1. 读取标签内的文本(Python) 如下的 xml 文 ...

  7. JDBC读取配置文件

    Properties prop = new Properties(); prop.load(this.class.getClassLoader().getResourceAsStream(" ...

  8. Spring3开发(一)

    1 Ioc是什么? Ioc:Inversion of Control,控制反转,控制权从应用程序转移到框架(如Ioc容器),是框架的共有特性. 1.1 为什么需要IoC容器?IoC容器是如何演变的? ...

  9. LeetCode之数组处理题java

    342. Power of Four Total Accepted: 7302 Total Submissions: 21876 Difficulty: Easy Given an integer ( ...

  10. WIN7下为Editplus添加右键打开

    解决某些特殊情况, EditPlus 3在Windows7下使用右键菜单无法编辑文件的问题.1.Ctrl+R运行regedit2.在 HKEY_CLASSES_ROOT\* 下新建项 shell3.在 ...