zoukankan      html  css  js  c++  java
  • numpy窗函数

    绘制巴特利特窗

    巴特利特窗是一种三角形平滑窗

    import numpy as np
    import matplotlib.pyplot as plt
    
    window = np.bartlett(42)
    
    plt.plot(window)
    plt.show()

    绘制布莱克曼窗

    布莱克曼窗形式上是三项余弦值的加和

    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib.dates import datestr2num
    
    closes = np.loadtxt('AAPL.csv', delimiter=',', usecols=(6,), 
                        converters={1:datestr2num}, unpack=True)
    N = 10
    window = np.blackman(N)
    smoothed = np.convolve(window/window.sum(), closes, mode="same")
    
    plt.plot(smoothed[N:-N], lw=2, label="smoothed")
    plt.plot(closes[N:-N], label="closes")
    plt.legend(loc="best")
    plt.show()

    绘制汉明窗

    汉明窗是一个加权的余弦函数

    hamming函数唯一的参数是输出点的个数

    import numpy as np
    import matplotlib.pyplot as plt
    
    window = np.hamming(142)
    plt.plot(window)
    plt.show()

    绘制凯泽窗

    凯泽窗是以贝塞尔函数定义的

    第一个参数为输出点的个数, 第二个参数为贝塞尔函数中的参数值

    import numpy as np
    import matplotlib.pyplot as plt
    
    window = np.kaiser(42, 14)
    plt.plot(window)
    plt.show()

    import numpy as np
    import matplotlib.pyplot as plt
    
    window = np.kaiser(42, 4)
    plt.plot(window)
    plt.show()

  • 相关阅读:
    10th blog:箭头函数
    10th blog:Event Flow
    12th:MAP.API
    10th blog:For each···in / For···in / For···of
    10th blog:Object
    Web第九周作业:History of Program(1950--2020)
    Web作业:Regular Expression
    Web作业:specific word count (index of )
    Web第七周作业:DOM&BOM
    MAP
  • 原文地址:https://www.cnblogs.com/draven123/p/11427206.html
Copyright © 2011-2022 走看看