Английская Википедия:Cross-correlation

Материал из Онлайн справочника
Перейти к навигацииПерейти к поиску

Шаблон:Short description Шаблон:Correlation and covariance

Файл:Comparison convolution correlation.svg
Visual comparison of convolution, cross-correlation and autocorrelation. For the operations involving function Шаблон:Mvar, and assuming the height of Шаблон:Mvar is 1.0, the value of the result at 5 different points is indicated by the shaded area below each point. Also, the vertical symmetry of Шаблон:Mvar is the reason <math>f*g</math> and <math>f \star g</math> are identical in this example.

In signal processing, cross-correlation is a measure of similarity of two series as a function of the displacement of one relative to the other. This is also known as a sliding dot product or sliding inner-product. It is commonly used for searching a long signal for a shorter, known feature. It has applications in pattern recognition, single particle analysis, electron tomography, averaging, cryptanalysis, and neurophysiology. The cross-correlation is similar in nature to the convolution of two functions. In an autocorrelation, which is the cross-correlation of a signal with itself, there will always be a peak at a lag of zero, and its size will be the signal energy.

In probability and statistics, the term cross-correlations refers to the correlations between the entries of two random vectors <math>\mathbf{X}</math> and <math>\mathbf{Y}</math>, while the correlations of a random vector <math>\mathbf{X}</math> are the correlations between the entries of <math>\mathbf{X}</math> itself, those forming the correlation matrix of <math>\mathbf{X}</math>. If each of <math>\mathbf{X}</math> and <math>\mathbf{Y}</math> is a scalar random variable which is realized repeatedly in a time series, then the correlations of the various temporal instances of <math>\mathbf{X}</math> are known as autocorrelations of <math>\mathbf{X}</math>, and the cross-correlations of <math>\mathbf{X}</math> with <math>\mathbf{Y}</math> across time are temporal cross-correlations. In probability and statistics, the definition of correlation always includes a standardising factor in such a way that correlations have values between −1 and +1.

If <math>X</math> and <math>Y</math> are two independent random variables with probability density functions <math>f</math> and <math>g</math>, respectively, then the probability density of the difference <math>Y - X</math> is formally given by the cross-correlation (in the signal-processing sense) <math>f \star g</math>; however, this terminology is not used in probability and statistics. In contrast, the convolution <math>f * g</math> (equivalent to the cross-correlation of <math>f(t)</math> and <math>g(-t)</math>) gives the probability density function of the sum <math>X + Y</math>.

Cross-correlation of deterministic signals

For continuous functions <math>f</math> and <math>g</math>, the cross-correlation is defined as:[1][2][3]<math display="block">(f \star g)(\tau)\ \triangleq \int_{-\infty}^{\infty} \overline{f(t)} g(t+\tau)\,dt</math>which is equivalent to<math display="block">(f \star g)(\tau)\ \triangleq \int_{-\infty}^{\infty} \overline{f(t-\tau)} g(t)\,dt</math>where <math>\overline{f(t)}</math> denotes the complex conjugate of <math>f(t)</math>, and <math>\tau</math> is called displacement or lag. For highly-correlated <math>f</math> and <math>g</math> which have a maximum cross-correlation at a particular <math>\tau</math>, a feature in <math>f</math> at <math>t</math> also occurs later in <math>g</math> at <math>t+\tau</math>, hence <math>g</math> could be described to lag <math>f</math> by <math>\tau</math>.

If <math>f</math> and <math>g</math> are both continuous periodic functions of period <math>T</math>, the integration from <math>-\infty</math> to <math>\infty</math> is replaced by integration over any interval <math>[t_0,t_0+T]</math> of length <math>T</math>:<math display="block">(f \star g)(\tau)\ \triangleq \int_{t_0}^{t_0+T} \overline{f(t)} g(t + \tau)\,dt</math>which is equivalent to<math display="block">(f \star g)(\tau)\ \triangleq \int_{t_0}^{t_0+T} \overline{f(t-\tau)} g(t)\,dt</math>Similarly, for discrete functions, the cross-correlation is defined as:[4][5]<math display="block">(f \star g)[n]\ \triangleq \sum_{m=-\infty}^{\infty} \overline{f[m]} g[m+n]</math>which is equivalent to:<math display="block">(f \star g)[n]\ \triangleq \sum_{m=-\infty}^{\infty} \overline{f[m - n]} g[m]</math>For finite discrete functions <math>f,g\in\mathbb{C}^N</math>, the (circular) cross-correlation is defined as:[6]<math display="block">(f \star g)[n]\ \triangleq \sum_{m=0}^{N-1} \overline{f[m]} g[(m+n)_{\text{mod}~N}]</math>which is equivalent to:<math display="block">(f \star g)[n]\ \triangleq \sum_{m=0}^{N-1} \overline{f[(m-n)_{\text{mod}~N}]} g[m]</math>For finite discrete functions <math>f\in\mathbb{C}^N</math>, <math>g\in\mathbb{C}^M</math>, the kernel cross-correlation is defined as:[7]<math display="block">(f \star g)[n]\ \triangleq \sum_{m=0}^{N-1} \overline{f[m]} K_g[(m+n)_{\text{mod}~N}]</math>where <math>K_g = [k(g, T_0(g)), k(g, T_1(g)), \dots, k(g, T_{N-1}(g))]</math> is a vector of kernel functions <math>k(\cdot, \cdot)\colon \mathbb{C}^M \times \mathbb{C}^M \to \mathbb{R}</math> and <math>T_i(\cdot)\colon \mathbb{C}^M \to \mathbb{C}^M</math> is an affine transform.

Specifically, <math>T_i(\cdot)</math> can be circular translation transform, rotation transform, or scale transform, etc. The kernel cross-correlation extends cross-correlation from linear space to kernel space. Cross-correlation is equivariant to translation; kernel cross-correlation is equivariant to any affine transforms, including translation, rotation, and scale, etc.

Explanation

As an example, consider two real valued functions <math>f</math> and <math>g</math> differing only by an unknown shift along the x-axis. One can use the cross-correlation to find how much <math>g</math> must be shifted along the x-axis to make it identical to <math>f</math>. The formula essentially slides the <math>g</math> function along the x-axis, calculating the integral of their product at each position. When the functions match, the value of <math>(f\star g)</math> is maximized. This is because when peaks (positive areas) are aligned, they make a large contribution to the integral. Similarly, when troughs (negative areas) align, they also make a positive contribution to the integral because the product of two negative numbers is positive.

Файл:Cross correlation animation.gif
Animation of how cross-correlation is calculated. The left graph shows a green function G that is phase-shifted relative to function F by a time displacement of 𝜏. The middle graph shows the function F and the phase-shifted G represented together as a Lissajous curve. Integrating F multiplied by the phase-shifted G produces the right graph, the cross-correlation across all values of 𝜏.

With complex-valued functions <math>f</math> and <math>g</math>, taking the conjugate of <math>f</math> ensures that aligned peaks (or aligned troughs) with imaginary components will contribute positively to the integral.

In econometrics, lagged cross-correlation is sometimes referred to as cross-autocorrelation.[8]Шаблон:Rp

Properties

Шаблон:Unordered list \cdot \mathcal{F}\left\{g\right\},</math>

where <math>\mathcal{F}</math> denotes the Fourier transform, and an <math>\overline{f}</math> again indicates the complex conjugate of <math>f</math>, since <math>\mathcal{F}\left\{\overline{f(-t)}\right\}=\overline{\mathcal{F}\left\{f(t)\right\}}</math>. Coupled with fast Fourier transform algorithms, this property is often exploited for the efficient numerical computation of cross-correlations[9] (see circular cross-correlation). | The cross-correlation is related to the spectral density (see Wiener–Khinchin theorem). | The cross-correlation of a convolution of <math>f</math> and <math>h</math> with a function <math>g</math> is the convolution of the cross-correlation of <math>g</math> and <math>f</math> with the kernel <math>h</math>:

<math>g \star \left(f * h\right) = \left(g \star f\right) * h</math>.

}}

Cross-correlation of random vectors

Шаблон:Main

Definition

For random vectors <math>\mathbf{X} = (X_1,\ldots,X_m)</math> and <math>\mathbf{Y} = (Y_1,\ldots,Y_n)</math>, each containing random elements whose expected value and variance exist, the cross-correlation matrix of <math>\mathbf{X}</math> and <math>\mathbf{Y}</math> is defined by[10]Шаблон:Rp<math display="block">\operatorname{R}_{\mathbf{X}\mathbf{Y}} \triangleq\ \operatorname{E}\left[\mathbf{X} \mathbf{Y}\right]</math>and has dimensions <math>m \times n</math>. Written component-wise:<math display="block">\operatorname{R}_{\mathbf{X}\mathbf{Y}} = \begin{bmatrix} \operatorname{E}[X_1 Y_1] & \operatorname{E}[X_1 Y_2] & \cdots & \operatorname{E}[X_1 Y_n] \\ \\ \operatorname{E}[X_2 Y_1] & \operatorname{E}[X_2 Y_2] & \cdots & \operatorname{E}[X_2 Y_n] \\ \\

\vdots & \vdots & \ddots & \vdots \\ \\

\operatorname{E}[X_m Y_1] & \operatorname{E}[X_m Y_2] & \cdots & \operatorname{E}[X_m Y_n] \end{bmatrix} </math>The random vectors <math>\mathbf{X}</math> and <math>\mathbf{Y}</math> need not have the same dimension, and either might be a scalar value. Where <math>\operatorname{E}</math> is the expectation value.

Example

For example, if <math>\mathbf{X} = \left( X_1,X_2,X_3 \right)</math> and <math>\mathbf{Y} = \left( Y_1,Y_2 \right)</math> are random vectors, then <math>\operatorname{R}_{\mathbf{X}\mathbf{Y}}</math> is a <math>3 \times 2</math> matrix whose <math>(i,j)</math>-th entry is <math>\operatorname{E}[X_i Y_j]</math>.

Definition for complex random vectors

If <math>\mathbf{Z} = (Z_1,\ldots,Z_m)</math> and <math>\mathbf{W} = (W_1,\ldots,W_n)</math> are complex random vectors, each containing random variables whose expected value and variance exist, the cross-correlation matrix of <math>\mathbf{Z}</math> and <math>\mathbf{W}</math> is defined by<math display="block">\operatorname{R}_{\mathbf{Z}\mathbf{W}} \triangleq\ \operatorname{E}[\mathbf{Z} \mathbf{W}^{\rm H}]</math>where <math>{}^{\rm H}</math> denotes Hermitian transposition.

Cross-correlation of stochastic processes

In time series analysis and statistics, the cross-correlation of a pair of random process is the correlation between values of the processes at different times, as a function of the two times. Let <math>(X_t, Y_t)</math> be a pair of random processes, and <math>t</math> be any point in time (<math>t</math> may be an integer for a discrete-time process or a real number for a continuous-time process). Then <math>X_t</math> is the value (or realization) produced by a given run of the process at time <math>t</math>.

Cross-correlation function

Suppose that the process has means <math>\mu_X(t)</math> and <math>\mu_Y(t)</math> and variances <math>\sigma_X^2(t)</math> and <math>\sigma_Y^2(t)</math> at time <math>t</math>, for each <math>t</math>. Then the definition of the cross-correlation between times <math>t_1</math> and <math>t_2</math> is[10]Шаблон:Rp<math display="block">\operatorname{R}_{XY}(t_1, t_2) \triangleq\ \operatorname{E}\left[X_{t_1} \overline{Y_{t_2}}\right]</math>where <math>\operatorname{E}</math> is the expected value operator. Note that this expression may be not defined.

Cross-covariance function

Subtracting the mean before multiplication yields the cross-covariance between times <math>t_1</math> and <math>t_2</math>:[10]Шаблон:Rp<math display="block">\operatorname{K}_{XY}(t_1, t_2) \triangleq\ \operatorname{E}\left[\left(X_{t_1} - \mu_X(t_1)\right)\overline{(Y_{t_2} - \mu_Y(t_2))}\right]</math>Note that this expression is not well-defined for all time series or processes, because the mean or variance may not exist.

Definition for wide-sense stationary stochastic process

Let <math>(X_t, Y_t)</math> represent a pair of stochastic processes that are jointly wide-sense stationary. Then the cross-covariance function and the cross-correlation function are given as follows.

Cross-correlation function

<math display="block">\operatorname{R}_{XY}(\tau) \triangleq\ \operatorname{E}\left[X_t \overline{Y_{t+\tau}}\right]</math> or equivalently <math display="block">\operatorname{R}_{XY}(\tau) = \operatorname{E}\left[X_{t-\tau} \overline{Y_{t}}\right]</math>

Cross-covariance function

<math display="block">\operatorname{K}_{XY}(\tau) \triangleq\ \operatorname{E}\left[\left(X_t - \mu_X\right)\overline{\left(Y_{t+\tau} - \mu_Y\right)}\right]</math> or equivalently <math display="block">\operatorname{K}_{XY}(\tau) = \operatorname{E}\left[\left(X_{t-\tau} - \mu_X\right)\overline{\left(Y_{t} - \mu_Y\right)}\right]</math>where <math>\mu_X</math> and <math>\sigma_X</math> are the mean and standard deviation of the process <math>(X_t)</math>, which are constant over time due to stationarity; and similarly for <math>(Y_t)</math>, respectively. <math>\operatorname{E}[\ ]</math> indicates the expected value. That the cross-covariance and cross-correlation are independent of <math>t</math> is precisely the additional information (beyond being individually wide-sense stationary) conveyed by the requirement that <math>(X_t, Y_t)</math> are jointly wide-sense stationary.

The cross-correlation of a pair of jointly wide sense stationary stochastic processes can be estimated by averaging the product of samples measured from one process and samples measured from the other (and its time shifts). The samples included in the average can be an arbitrary subset of all the samples in the signal (e.g., samples within a finite time window or a sub-samplingШаблон:Which of one of the signals). For a large number of samples, the average converges to the true cross-correlation.

Normalization

It is common practice in some disciplines (e.g. statistics and time series analysis) to normalize the cross-correlation function to get a time-dependent Pearson correlation coefficient. However, in other disciplines (e.g. engineering) the normalization is usually dropped and the terms "cross-correlation" and "cross-covariance" are used interchangeably.

The definition of the normalized cross-correlation of a stochastic process is<math display="block">

 \rho_{XX}(t_1, t_2) =
 \frac{\operatorname{K}_{XX}(t_1, t_2)}{\sigma_X(t_1)\sigma_X(t_2)} =
 \frac{\operatorname{E}\left[\left(X_{t_1} - \mu_{t_1}\right)\overline{\left(X_{t_2} - \mu_{t_2}\right)}\right]}{\sigma_X(t_1)\sigma_X(t_2)}

</math>If the function <math>\rho_{XX}</math> is well-defined, its value must lie in the range <math>[-1,1]</math>, with 1 indicating perfect correlation and −1 indicating perfect anti-correlation.

For jointly wide-sense stationary stochastic processes, the definition is<math display="block">

 \rho_{XY}(\tau) =
 \frac{\operatorname{K}_{XY}(\tau)}{\sigma_X \sigma_Y} =
 \frac{\operatorname{E}\left[\left(X_t - \mu_X\right) \overline{\left(Y_{t+\tau} - \mu_Y\right)}\right]}{\sigma_X \sigma_Y}

</math>The normalization is important both because the interpretation of the autocorrelation as a correlation provides a scale-free measure of the strength of statistical dependence, and because the normalization has an effect on the statistical properties of the estimated autocorrelations.

Properties

Symmetry property

For jointly wide-sense stationary stochastic processes, the cross-correlation function has the following symmetry property:[11]Шаблон:Rp<math display="block">\operatorname{R}_{XY}(t_1, t_2) = \overline{\operatorname{R}_{YX}(t_2, t_1)}</math>Respectively for jointly WSS processes:<math display="block">\operatorname{R}_{XY}(\tau) = \overline{\operatorname{R}_{YX}(-\tau)}</math>

Time delay analysis

Cross-correlations are useful for determining the time delay between two signals, e.g., for determining time delays for the propagation of acoustic signals across a microphone array.[12][13]Шаблон:Clarify After calculating the cross-correlation between the two signals, the maximum (or minimum if the signals are negatively correlated) of the cross-correlation function indicates the point in time where the signals are best aligned; i.e., the time delay between the two signals is determined by the argument of the maximum, or arg max of the cross-correlation, as in<math display="block">\tau_\mathrm{delay}=\underset{t \in \mathbb{R}}{\operatorname{arg\,max}}((f \star g)(t))</math>Terminology in image processing

Zero-normalized cross-correlation (ZNCC)

Animation of the normalized cross-correlation sliding a template over an image. Image and template are consecutive frames of particles in a flow field. This technique is also called Particle Image Velocimetry.
Animation of the normalized cross-correlation sliding a template over an image. Image and template are consecutive frames of particles in a flow field. This technique is also called Particle Image Velocimetry.

For image-processing applications in which the brightness of the image and template can vary due to lighting and exposure conditions, the images can be first normalized. This is typically done at every step by subtracting the mean and dividing by the standard deviation. That is, the cross-correlation of a template <math>t(x,y)</math> with a subimage <math>f(x,y)</math> is


<math display="block">\frac{1}{n} \sum_{x,y}\frac{1}{\sigma_f \sigma_t}\left(f(x,y) - \mu_f \right)\left(t(x,y) - \mu_t \right)</math>


where <math>n</math> is the number of pixels in <math>t(x,y)</math> and <math>f(x,y)</math>, <math>\mu_f</math> is the average of <math>f</math> and <math>\sigma_f</math> is standard deviation of <math>f</math>.

In functional analysis terms, this can be thought of as the dot product of two normalized vectors. That is, if<math display="block">F(x,y) = f(x,y) - \mu_f</math>and<math display="block">T(x,y) = t(x,y) - \mu_t</math>then the above sum is equal to<math display="block">\left\langle\frac{F}{\|F\|},\frac{T}{\|T\|}\right\rangle</math>where <math>\langle\cdot,\cdot\rangle</math> is the inner product and <math>\|\cdot\|</math> is the L² norm. Cauchy–Schwarz then implies that ZNCC has a range of <math>[-1, 1]</math>.

Thus, if <math>f</math> and <math>t</math> are real matrices, their normalized cross-correlation equals the cosine of the angle between the unit vectors <math>F</math> and <math>T</math>, being thus <math>1</math> if and only if <math>F</math> equals <math>T</math> multiplied by a positive scalar.

Normalized correlation is one of the methods used for template matching, a process used for finding instances of a pattern or object within an image. It is also the 2-dimensional version of Pearson product-moment correlation coefficient.

Normalized cross-correlation (NCC)

NCC is similar to ZNCC with the only difference of not subtracting the local mean value of intensities:<math display="block">\frac{1}{n} \sum_{x,y}\frac{1}{\sigma_f \sigma_t} f(x,y) t(x,y)</math>

Nonlinear systems

Caution must be applied when using cross correlation for nonlinear systems. In certain circumstances, which depend on the properties of the input, cross correlation between the input and output of a system with nonlinear dynamics can be completely blind to certain nonlinear effects.[14] This problem arises because some quadratic moments can equal zero and this can incorrectly suggest that there is little "correlation" (in the sense of statistical dependence) between two signals, when in fact the two signals are strongly related by nonlinear dynamics.

See also

Шаблон:Div col

Шаблон:Div col end

References

Шаблон:Reflist

Further reading

External links

Шаблон:Statistics

  1. Bracewell, R. "Pentagram Notation for Cross Correlation." The Fourier Transform and Its Applications. New York: McGraw-Hill, pp. 46 and 243, 1965.
  2. Papoulis, A. The Fourier Integral and Its Applications. New York: McGraw-Hill, pp. 244–245 and 252-253, 1962.
  3. Weisstein, Eric W. "Cross-Correlation." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/Cross-Correlation.html
  4. Шаблон:Cite book
  5. Шаблон:Cite book
  6. Шаблон:Cite thesis
  7. Шаблон:Cite journal
  8. Шаблон:Cite book
  9. Шаблон:Cite book
  10. 10,0 10,1 10,2 Шаблон:Cite book
  11. Kun Il Park, Fundamentals of Probability and Stochastic Processes with Applications to Communications, Springer, 2018, 978-3-319-68074-3
  12. Шаблон:Cite conference
  13. Шаблон:Cite thesis
  14. Шаблон:Cite book