cross_correlation#

sunkit_image.time_lag.cross_correlation(signal_a, signal_b, lags: Unit('s'))[source]#

Compute cross-correlation between two signals, as a function of lag.

By the convolution theorem the cross-correlation between two signals can be computed as,

\[\begin{split}\mathcal{C}_{AB}(\tau) &= \mathcal{I}_A(t)\star\mathcal{I}_B(t) \\ &= \mathcal{I}_A(-t)\ast\mathcal{I}_B(t) \\ &= \mathscr{F}^{-1}\{\mathscr{F}\{\mathcal{I}_A(-t)\}\mathscr{F}\{\mathcal{I}_B(t)\}\}\end{split}\]

where each signal has been centered and scaled by its mean and standard deviation,

\[\mathcal{I}_c(t)=\frac{I_c(t)-\bar{I}_c}{\sigma_{c}}\]

Additionally, \(\mathcal{C}_{AB}\) is normalized by the length of the time series.

Parameters:
  • signal_a (array-like) – The first dimension should correspond to the time dimension and must have length (len(lags) + 1)/2.

  • signal_b (array-like) – Must have the same dimensions as signal_a.

  • lags (Quantity) – Evenly spaced time lags corresponding to the time dimension of signal_a and signal_b running from -max(time) to max(time). This is easily constructed using get_lags()

Returns:

array-like – Cross-correlation as a function of lags. The first dimension will be the same as that of lags and the subsequent dimensions will be consistent with dimensions of signal_a and signal_b.

References