互相关在 scipy、python 中给出不正确的结果
我有一个带有数字的向量 x
,然后创建一个移位副本并执行互相关,但我发现相关性最高的滞后为 0。我尝试对向量执行相同的操作具有相同大小的正态分布数字,然后它就可以工作。我还注意到,如果我只使用向量的一小部分,它也可以工作......
def align_time_series(a, b):
mode="full"
correlation = signal.correlate(a, b, mode=mode)
lags = correlation_lags(a.size, b.size, mode=mode)
lags_corr = pd.Series(correlation, lags)
lags_corr.plot()
print(lags_corr.idxmax())
plt.axvline(lags_corr.idxmax())
plt.show()
y = x[2000:]
align_time_series(x, y)
# => best lag is 0?
I have a vector x
with numbers and then I create a shifted copy and perform cross correlation, but yet I get that the lag with highest correlation is 0. I've tried to do the same with a vector with normally distributed numbers of the same size and then it works. I've also noticed that if I just use a smaller part of the vector it also works...
def align_time_series(a, b):
mode="full"
correlation = signal.correlate(a, b, mode=mode)
lags = correlation_lags(a.size, b.size, mode=mode)
lags_corr = pd.Series(correlation, lags)
lags_corr.plot()
print(lags_corr.idxmax())
plt.axvline(lags_corr.idxmax())
plt.show()
y = x[2000:]
align_time_series(x, y)
# => best lag is 0?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论