synthetic.py 文件源码

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

项目:extract 作者: dblalock 项目源码 文件源码
def notSoRandomWalk(shape, std=1, trendFilterLength=32, lpfLength=16):
    """bandpass filter a random walk so that the low-frequency trend /
    drift is eliminated and the high-frequency noise is attenuated"""
    walk = randwalk(shape, std=std)
    filt = np.hamming(trendFilterLength)
    filt /= np.sum(filt)
    whichAxis = len(walk.shape) > 1 # 0 iff 1d, else 1
    # subtract baseline drift, roughly
    trend = filters.convolve1d(walk, weights=filt, axis=whichAxis, mode='reflect')
    walk -= trend
    # subtract noisey spikes
    walk = filters.convolve1d(walk, weights=np.hamming(lpfLength), axis=whichAxis, mode='reflect')
    return walk
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号