计算互相关函数?

编程入门 行业动态 更新时间:2024-10-26 06:39:10
本文介绍了计算互相关函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在R中,我正在使用ccf或acf计算成对互相关函数,以便我可以找出哪个偏移使我获得了最大值.从它的外观来看,R给我一个规范化的值序列. Python的scipy中是否有类似的东西,还是应该使用fft模块来做到这一点?目前,我正在执行以下操作:

In R, I am using ccf or acf to compute the pair-wise cross-correlation function so that I can find out which shift gives me the maximum value. From the looks of it, R gives me a normalized sequence of values. Is there something similar in Python's scipy or am I supposed to do it using the fft module? Currently, I am doing it as follows:

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)

推荐答案

要交叉关联1d数组,请使用 numpy.correlate .

To cross-correlate 1d arrays use numpy.correlate.

对于2d数组,请使用 scipy.signal.correlate2d .

For 2d arrays, use scipy.signal.correlate2d.

还有 scipy .stsci.convolve.correlate2d .

还有 matplotlib.pyplot.xcorr 这是基于numpy.correlate.

There is also matplotlib.pyplot.xcorr which is based on numpy.correlate.

请参见SciPy邮件列表上的此信息一些指向不同实现的链接.

See this post on the SciPy mailing list for some links to different implementations.

@ user333700添加了指向此问题的科学票证.

@user333700 added a link to the SciPy ticket for this issue in a comment.

更多推荐

计算互相关函数?

本文发布于:2023-11-30 05:18:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1648856.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:函数

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!