I have a large number (M) of time series, each with N time points, stored in an MxN matrix. Then I also have a separate time series with N time points that I would like to correlate with all the time series in the matrix.
An easy solution is to go through the matrix row by row and run numpy.corrcoef. However, I was wondering if there is a faster or more concise way to do this?
Let's use this
correlationformula :You can implement this for
Xas theM x Narray andYas the other separate time series array ofNelements to becorrelatedwithX. So, assumingXandYasAandBrespectively, a vectorized implementation would look something like this -Verify results -