Python中两个标准化时间序列信号之间的功率相关性? [英] Power correlation between two normalized time-series signals in Python?

查看:338
本文介绍了Python中两个标准化时间序列信号之间的功率相关性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个归一化([1,0])信号(已附加图像).每个信号都有许多峰和谷.但是,两个信号在大约相同的时间具有最大值(在附图中,在2.5秒时,两个信号的最大值均为1.0).我想在两个信号之间进行相关,以使最大值为2.5 s.当我运行numpy.correlate时,在不同于最大值的时间步长处得到一个峰值.如何在2.5 s的时间获得最大的相关峰?任何想法/建议都会有很大帮助.谢谢!

I have two normalized ([1,0]) signals (images attached). Each signal has many peaks and dips. However, both signal have a maximum at approximately same time (in the attached pics, at 2.5 seconds both signals have maximum value of 1.0). I would to like to run correlation between two signals to have the maximum be at 2.5 s. When I run numpy.correlate, I get a peak at a different time step than where the maximum values are. How can I get a maximum correlation peak at time 2.5 s? Any ideas/suggestions would help greatly. Thanks!

推荐答案

要在正确的位置接收峰,必须除以求和元素的数量.可以使用numpy/scipy函数轻松地忽略这一点,该函数求和但不除以长度.

To receive a peak at the right location you have to divide by the number of the summed elements. This can be easily overlooked using the numpy/scipy functions which sums but do not divide by the length.

from scipy.signal import correlate

corr = correlate(x1, x2, 'same')
norm_arr = np.concatenate((np.arange(x1.size / 2)[::-1], np.arange(x1.size / 2)))
corrected_corr = corr / (samples.size - norm_arr)/(np.std(x1)*np.std(x2))

这篇关于Python中两个标准化时间序列信号之间的功率相关性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆