I have a time series of vector data -- each point being a 2D vector. I would like to calculate an autocorrelation (or something like it -- excuse me if I'm misusing the language here). Let's say the vector at time t is v(t). What I want is to calculate vector dot products so that my correlation looks like:
C(T) = ∑ v⃗(t) · v⃗(t+T)
summed over all t s.t. v(t) and v(t+T) exist.
Is there a clean, compact way to do this with numpy? (Would be happy to give a try to answers from scipy etc. too.) Thanks.
I will assume
v
has the following format:Extract the two components:
Then use correlate to calculate the per-component correlation:
You will only need half of the result as the correlation is symmetric. The correct half would be: