zoukankan      html  css  js  c++  java
  • np.convolve

    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.

    >>> N=3
    >>> weights = np.ones(N) / N
    >>> weights
    array([ 0.33333333,  0.33333333,  0.33333333])
    
    >>> c=[2,3,5]
    >>> np.convolve(weights, c)
    array([ 0.66666667,  1.66666667,  3.33333333,  2.66666667,  1.66666667])
    
    >>> np.convolve(weights, c,'same')
    array([ 1.66666667,  3.33333333,  2.66666667])
    
    >>> np.convolve(weights, c,'valid')
    array([ 3.33333333])
    
    >>> c=[2,3,6,2,7,9,10]
    
    >>> np.convolve(weights, c)
    array([ 0.66666667,  1.66666667,  3.66666667,  3.66666667,  5.        ,
            6.        ,  8.66666667,  6.33333333,  3.33333333])
    
    >>> np.convolve(weights, c,'same')
    array([ 1.66666667,  3.66666667,  3.66666667,  5.        ,  6.        ,
            8.66666667,  6.33333333])
    
    >>> np.convolve(weights, c,'valid')
    array([ 3.66666667,  3.66666667,  5.        ,  6.        ,  8.66666667])
    

     多用于计算移动平均,参数的不同之处在于边界的处理。

  • 相关阅读:
    this与$(this)的区别
    子元素筛选选择器
    内容筛选选择器
    基本筛选选择器
    jQuery对象与DOM对象及互相转化
    【题解】保安站岗[P2458]皇宫看守[LOJ10157][SDOI2006]
    【学习笔记】薛定谔的喵咪Cat—球盒问题(全详解)
    【题解】二逼平衡树 [P3380] [BZOJ3196] [Tyvj1730]
    【题解】TES-Intelligence Test
    【题解】自行车比赛 [AHOI2016] [P2777]
  • 原文地址:https://www.cnblogs.com/nicolexu/p/5960757.html
Copyright © 2011-2022 走看看