0
$\begingroup$

I have two discrete signals x1 and x2 with corresponding time points t1 and t2 and I want to take the cross correlation between x1 and x2 to see if there is any similarity at a given time time shift. However, the time samples are at slightly different discrete time points, e.g:

t1 = [0, 1, 3, 5, 6, 8]

t2 = [0, 2, 3, 4, 7, 9]

How can I take the cross correlation between x1 and x2 in this case? From what I can see the Python function scipy.signal.correlate() assumes that the samples in x1 and x2 are taken at identical time points.

$\endgroup$

1 Answer 1

0
$\begingroup$

There are multiply approaches for doing so. In any way, it would be a good idea to use some more knowledge about the concrete setting to decide for the right way. Without this knowledge, I just name some possible options:

Intersection

You could reduce your time series to the points in time, that appear in both. in your case, that would be t=[0,3].
Probably, this is a very strong reduction in your case and does not lead to the desired results. I would only use this approach, if there is (nearly) independence between nearby measurements, i.e. that the measurement if x1 at time 5 and 6 are independent.

Interpolation

You could interpolate between the measurements. The choice of a good interpolation method depends on your concrete setting.

The tricky part here is to decide for the right points in time that you use for your cross-correlation-computation. You could:

  • Take the time points of one series and only interpolate on the other one. The problem is, that this is not symmetric and you could get different correlations for choosing x1 or x2 as reference series.
  • Take the union of all time points. The problem here is, that you might include some bias in in the computation, since points that differ are slightly will count twice, while identical points will only count once.
  • If you can identify time-points (e.g. 0 with 0, 1 with 2, 3 with 3, ...), you could take the mean of each pair, i.e. t=[0, 1.5, 3, 4.5, 6.5, 8.5] in your case
  • Finally, you could create time points independent of the original ones, e.g. [0,1,2,3,4,5,6,7,8,9]. Due to the disadvantages of interpolations, all these points should ideally be close to real time points.

I hope my answer gives you some approaches how to handle you problem.

$\endgroup$
1
  • $\begingroup$ Thanks for your answer there are some interesting ideas there I will test them out. I have around 6k data points and the differences in time between samples t1 and t2 are around ~1-2 sec. The difference between adjacent samples is ~5sec. I was trying to keep as much resolution in my dataset as possible but I might try averaging to make t1 and t2 correspond to each other more strongly. $\endgroup$
    – hokge
    Dec 28, 2022 at 23:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.