为什么使用 DFT 进行关联会给出不直观的结果?
我试图通过 Matlab 中的 DFT(数字傅里叶变换)使用相关性来比较 2 个信号的相似程度,但相关函数给出的结果并不是真正可预测的。例如,如果我比较这两对信号:
- 相关性 1 和 2
- 相关性 3 和 4(自相关)
我预计“corr 3 和 4”情况下的相关峰值高于“corr 1 和 2”情况下的相关峰值。
我也尝试使信号“平均为零”,但这没有帮助。
这是预期的结果还是我错过了一些预处理等?
I was trying to compare how similar 2 signals using correlation via DFT (Digital Fourier Transform) in Matlab, but the correlation function gives not really predictable results. For example, if I compare those 2 pairs of signals :
- correlation 1 and 2
- correlation 3 and 4 (autocorrelation)
I would expect correlation peak in "corr 3 and 4" case higher than in "corr 1 and 2" case.
I as also tried to make signals "average to zero", but this did not help.
Is this the expected result or did I miss some preprocessing, etc.?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要标准化您的数据轨迹 - 即在关联之前将它们除以各自的积分。以下代码演示了当您标准化数据轨迹时,自相关确实为您提供了更大的值:
导致
我放大了峰值以显示归一化自相关具有比归一化互相关更高的峰值。
You need to normalize your data traces - i.e. divide them by their respective integrals before correlating. The following code demonstrates that when you normalize your data traces, the autocorrelation indeed gives you the larger value:
leading to
where I zoomed in on the peaks to show the normalized autocorrelation has a higher peak than the normalized cross-correlation.
@Jonas,我无法找到如何插入图像并进行足够好的格式(对不起,这里是新手)评论你的答案,所以我将此评论保留为“答案”。
因此,我发现对于下图,您的方法给出了预期的结果:
如您所见 - 峰值自相关低于互相关。
我使用的代码如下:
@Jonas, I was unable to find how to insert image and make good enough formatting (sorry, novice here) commenting your answer, so I am leaving this comment as "answer".
So, what I found that for following figures your method giving not expected results:
as you see - peak for auto-correlation is lower than for cross correlation.
Code which I used is below: