In R
, 我在用ccf
or acf
计算成对互相关函数,以便我可以找出哪个移位给我带来最大值。从它的外观来看,R
给我一个标准化的值序列。 Python 的 scipy 中是否有类似的东西,或者我应该使用fft
模块?目前,我正在这样做:
xcorr = lambda x,y : irfft(rfft(x)*rfft(y[::-1]))
x = numpy.array([0,0,1,1])
y = numpy.array([1,1,0,0])
print xcorr(x,y)
要交叉关联一维数组,请使用numpy.关联 http://docs.scipy.org/doc/numpy/reference/generated/numpy.correlate.html.
对于二维数组,使用scipy.signal.correlate2d http://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.correlate2d.html.
还有scipy.stsci.convolve.correlate2d http://docs.scipy.org/doc/scipy-0.7.x/reference/generated/scipy.stsci.convolve.correlate2d.html.
还有matplotlib.pyplot.xcorr http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.xcorr它基于 numpy.correlate。
See SciPy 邮件列表上的这篇文章 http://mail.scipy.org/pipermail/scipy-user/2009-April/020570.html一些不同实现的链接。
编辑:@user333700 添加了一个链接本期的 SciPy 票证 https://web.archive.org/web/20120608210737/http://projects.scipy.org/numpy/ticket/1260在评论中。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)