估计两个时间序列之间的小时间偏移

编程入门 行业动态 更新时间:2024-10-28 16:25:19
本文介绍了估计两个时间序列之间的小时间偏移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有两个时间序列,我怀疑它们之间存在时间偏移,我想估计这个时间偏移.

I have two time series, and i suspect that there is a time shift between them, and i want to estimate this time shift.

这个问题之前有人问过:求两个(非和谐)波之间的相位差和找到两个相似波形之间的时移 但在我的情况下,时移小于数据的分辨率.例如,数据以每小时的分辨率提供,时移只有几分钟(见图).

This question has been asked before in: Find phase difference between two (inharmonic) waves and find time shift between two similar waveforms but in my case, the time shift is smaller than the resolution of the data. for example the data is available at hourly resolution, and the time shift is only few minutes(see image).

造成这种情况的原因是用于测量其中一个系列的数据记录器的时间有几分钟的变化.

The cause of this is that the datalogger used to measure one of the series has few minutes shift in its time.

任何可以估计这种偏移的算法,最好不使用插值?

Any algorithms out there that can estimate this shift, preferably without using interpolation?

推荐答案

这是一个很有趣的问题.这是使用傅立叶变换的部分解决方案的尝试.这依赖于适度周期性的数据.我不确定它是否适用于您的数据(端点处的导数似乎不匹配).

This is quite an interesting problem. Here's an attempt at a partial solution using fourier transforms. This relies on the data being moderately periodic. I'm not sure if it will work with your data (where the derivatives at the endpoints don't seem to match).

import numpy as np X = np.linspace(0,2*np.pi,30) #some X values def yvals(x): return np.sin(x)+np.sin(2*x)+np.sin(3*x) Y1 = yvals(X) Y2 = yvals(X-0.1) #shifted y values #fourier transform both series FT1 = np.fft.fft(Y1) FT2 = np.fft.fft(Y2) #You can show that analyically, a phase shift in the coefficients leads to a #multiplicative factor of `exp(-1.j * N * T_d)` #can't take the 0'th element because that's a division by 0. Analytically, #the division by 0 is OK by L'hopital's<sp?> rule, but computers don't know calculus :) print np.log(FT2[1:]/FT1[1:])/(-1.j*np.arange(1,len(X)))

对打印输出的快速检查表明,具有最多power (N=1,N=2) 给出合理的估计,如果你看一下 N=3 也可以绝对值 (np.absolute),虽然我无法解释为什么会这样.

A quick inspection of the printed output shows that the frequencies with the most power (N=1,N=2) give reasonable estimates, N=3 does OK too if you look at the absolute value (np.absolute), although I'm at a loss to explain why that would be.

也许更熟悉数学的人可以从这里得到更好的答案......

Maybe someone more familiar with the math can take it from here to give a better answer...

更多推荐

估计两个时间序列之间的小时间偏移

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

发布评论

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

>www.elefans.com

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