tools.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:spikes 作者: mozilla 项目源码 文件源码
def ma(x, win):
    """Compute the moving average of x with a window equal to win

    Args:
        x (numpy.array): data
        win (int): window

    Returns:
        numpy.array: the smoothed data
    """
    y = np.ones(win, dtype=np.float64)
    i = win - 1
    _x = np.convolve(x, y, mode='full')[:-i]
    _x[1:i] = _x[1:i] / np.arange(2., win, dtype=np.float64)
    _x[i:] = _x[i:] / float(win)

    return _x
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号