Cross-correlation
≈ 16 min read
Names in other languages
No names in other languages are held for this entry yet.
Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.
, cross-correlation and autocorrelation. For the operations involving function , and assuming the height of 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 is the reason f*g and f \star g 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 \mathbf{X} and \mathbf{Y} , while the correlations of a random vector \mathbf{X} are the correlations between the entries of \mathbf{X} itself, those forming the correlation matrix of \mathbf{X} .…
, cross-correlation and autocorrelation. For the operations involving function , and assuming the height of 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 is the reason f*g and f \star g 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 \mathbf{X} and \mathbf{Y} , while the correlations of a random vector \mathbf{X} are the correlations between the entries of \mathbf{X} itself, those forming the correlation matrix of \mathbf{X} . If each of \mathbf{X} and \mathbf{Y} is a scalar random variable which is realized repeatedly in a time series, then the correlations of the various temporal instances of \mathbf{X} are known as autocorrelations of \mathbf{X} , and the cross-correlations of \mathbf{X} with \mathbf{Y} 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 X and Y are two independent random variables with probability density functions f and g , respectively, then the probability density of the difference Y - X is formally given by the cross-correlation (in the signal-processing sense) f \star g ; however, this terminology is not used in probability and statistics. In contrast, the convolution f * g (equivalent to the cross-correlation of \overline{f(-t)} and g(t) ) gives the probability density function of the sum X + Y . ==Cross-correlation of deterministic signals== For continuous functions f and g , the cross-correlation is defined as: (f \star g)(\tau)\ \triangleq \int_{-\infty}^{\infty} \overline{f(t)} g(t+\tau)\,dt which is equivalent to (f \star g)(\tau)\ \triangleq \int_{-\infty}^{\infty} \overline{f(t-\tau)} g(t)\,dt where \overline{f(t)} denotes the complex conjugate of f(t) , and \tau is called displacement or lag. For highly-correlated f and g which have a maximum cross-correlation at a particular \tau , a feature in f at t also occurs later in g at t+\tau , hence g could be described to lag f by \tau . If f and g are both continuous periodic functions of period T , the integration from -\infty to \infty is replaced by integration over any interval [t_0,t_0+T] of length T : (f \star g)(\tau)\ \triangleq \int_{t_0}^{t_0+T} \overline{f(t)} g(t + \tau)\,dt which is equivalent to (f \star g)(\tau)\ \triangleq \int_{t_0}^{t_0+T} \overline{f(t-\tau)} g(t)\,dt Similarly, for discrete functions, the cross-correlation is defined as: (f \star g)[n]\ \triangleq \sum_{m=-\infty}^{\infty} \overline{f[m]} g[m+n] which is equivalent to: (f \star g)[n]\ \triangleq \sum_{m=-\infty}^{\infty} \overline{f[m - n]} g[m] For finite discrete functions f,g\in\mathbb{C}^N , the (circular) cross-correlation is defined as: (f \star g)[n]\ \triangleq \sum_{m=0}^{N-1} \overline{f[m]} g[(m+n)_{\text{mod}~N}] which is equivalent to: (f \star g)[n]\ \triangleq \sum_{m=0}^{N-1} \overline{f[(m-n)_{\text{mod}~N}]} g[m] For finite discrete functions f\in\mathbb{C}^N , g\in\mathbb{C}^M , the kernel cross-correlation is defined as: (f \star g)[n]\ \triangleq \sum_{m=0}^{N-1} \overline{f[m]} K_g[(m+n)_{\text{mod}~N}] where K_g = [k(g, T_0(g)), k(g, T_1(g)), \dots, k(g, T_{N-1}(g))] is a vector of kernel functions k(\cdot, \cdot)\colon \mathbb{C}^M \times \mathbb{C}^M \to \mathbb{R} and T_i(\cdot)\colon \mathbb{C}^M \to \mathbb{C}^M is an affine transform. Specifically, T_i(\cdot) 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 f and g differing only by an unknown shift along the x-axis. One can use the cross-correlation to find how much g must be shifted along the x-axis to make it identical to f . The formula essentially slides the g function along the x-axis, calculating the integral of their product at each position. When the functions match, the value of (f\star g) 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. . Integrating F multiplied by the phase-shifted G produces the right graph, the cross-correlation across all values of 𝜏.]] With complex-valued functions f and g , taking the conjugate of f 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. ===Properties=== {{unordered list | The cross-correlation of functions f(t) and g(t) is equivalent to the convolution (denoted by * ) of \overline{f(-t)} and g(t) . That is: [f(t) \star g(t)](t) = [\overline{f(-t)} * g(t)](t). | [f(t) \star g(t)](t) = [\overline{g(t)} \star \overline{f(t)}](-t). | If f is a Hermitian function, then f \star g = f * g. | If both f and g are Hermitian, then f \star g = g \star f . | \left(f \star g\right) \star \left(f \star g\right) = \left(f \star f\right) \star \left(g \star g\right) . | Analogous to the convolution theorem, the cross-correlation satisfies \mathcal{F}\left\{f \star g\right\} = \overline{\mathcal{F} \left\{f\right\}} \cdot \mathcal{F}\left\{g\right\}, where \mathcal{F} denotes the Fourier transform, and an \overline{f} again indicates the complex conjugate of f , since \mathcal{F}\left\{\overline{f(-t)}\right\}=\overline{\mathcal{F}\left\{f(t)\right\}} . Coupled with fast Fourier transform algorithms, this property is often exploited for the efficient numerical computation of cross-correlations (see circular cross-correlation). | The cross-correlation is related to the spectral density (see Wiener–Khinchin theorem). | The cross-correlation of a convolution of f and h with a function g is the convolution of the cross-correlation of g and f with the kernel h : g \star \left(f * h\right) = \left(g \star f\right) * h . }} ==Cross-correlation of random vectors== ===Definition=== For random vectors \mathbf{X} = (X_1,\ldots,X_m) and \mathbf{Y} = (Y_1,\ldots,Y_n) , each containing random elements whose expected value and variance exist, the cross-correlation matrix of \mathbf{X} and \mathbf{Y} is defined by \operatorname{R}_{\mathbf{X}\mathbf{Y}} \triangleq\ \operatorname{E}\left[\mathbf{X} \mathbf{Y}\right] and has dimensions m \times n . Written component-wise: \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} The random vectors \mathbf{X} and \mathbf{Y} need not have the same dimension, and either might be a scalar value. Where \operatorname{E} is the expectation value. ===Example=== For example, if \mathbf{X} = \left( X_1,X_2,X_3 \right) and \mathbf{Y} = \left( Y_1,Y_2 \right) are random vectors, then \operatorname{R}_{\mathbf{X}\mathbf{Y}} is a 3 \times 2 matrix whose (i,j) -th entry is \operatorname{E}[X_i Y_j] . ===Definition for complex random vectors=== If \mathbf{Z} = (Z_1,\ldots,Z_m) and \mathbf{W} = (W_1,\ldots,W_n) are complex random vectors, each containing random variables whose expected value and variance exist, the cross-correlation matrix of \mathbf{Z} and \mathbf{W} is defined by \operatorname{R}_{\mathbf{Z}\mathbf{W}} \triangleq\ \operatorname{E}[\mathbf{Z} \mathbf{W}^{\rm H}] where {}^{\rm H} 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 (X_t, Y_t) be a pair of random processes, and t be any point in time ( t may be an integer for a discrete-time process or a real number for a continuous-time process). Then X_t is the value (or realization) produced by a given run of the process at time t . Suppose that the process has means \mu_X(t) and \mu_Y(t) and variances \sigma_X^2(t) and \sigma_Y^2(t) at time t , for each t . Then the definition of the cross-correlation between times t_1 and t_2 is \operatorname{R}_{XY}(t_1, t_2) \triangleq\ \operatorname{E}\left[\overline{X_{t_1}} Y_{t_2}\right] where \operatorname{E} is the expected value operator. Note that this expression may be not defined. Subtracting the mean before multiplication yields the cross-covariance between times t_1 and t_2 : \operatorname{K}_{XY}(t_1, t_2) \triangleq\ \operatorname{E}\left[\overline{\left(X_{t_1} - \mu_X(t_1)\right)}(Y_{t_2} - \mu_Y(t_2))\right] 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 (X_t, Y_t) represent a pair of stochastic processes that are jointly wide-sense stationary. Then the cross-covariance function and the cross-correlation function are a function only of time lag \tau=t_2-t_1 (not absolute time), and are given as follows. ====Cross-correlation function==== \operatorname{R}_{XY}(\tau) \triangleq\ \operatorname{E}\left[\overline{X_t} Y_{t+\tau}\right] or equivalently \operatorname{R}_{XY}(\tau) = \operatorname{E}\left[\overline{X_{t-\tau}} Y_{t}\right] This definition is used by Newland . Note that some references including Gubner use an alternative convention \operatorname{R}_{XY}(\tau) = \operatorname{E}\left[X_{t+\tau}\overline{Y}\right] , which is equivalent to reversing the sign of the time lag and (for complex-valued processes) taking the complex conjugate. The resulting spectrum will be the complex conjugate of one obtained based on the other convention. ==== Cross-covariance function==== \operatorname{K}_{XY}(\tau) \triangleq\ \operatorname{E}\left[\overline{\left(X_t - \mu_X\right)}\left(Y_{t+\tau} - \mu_Y\right)\right] or equivalently \operatorname{K}_{XY}(\tau) = \operatorname{E}\left[\overline{\left(X_{t-\tau} - \mu_X\right)}\left(Y_{t} - \mu_Y\right)\right] where \mu_X and \sigma_X are the mean and standard deviation of the process (X_t) , which are constant over time due to stationarity; and similarly for (Y_t) , respectively. \operatorname{E}[\ ] indicates the expected value. That the cross-covariance and cross-correlation are independent of t is precisely the additional information (beyond being individually wide-sense stationary) conveyed by the requirement that (X_t, Y_t) 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 of one of the signals). For a large number of samples, the average converges to the true cross-correlation. The definition of the normalized cross-correlation of a stochastic process is \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[\overline{\left(X_{t_1} - \mu_{t_1}\right)}\left(X_{t_2} - \mu_{t_2}\right)\right]}{\sigma_X(t_1)\sigma_X(t_2)} If the function \rho_{XX} is well-defined, its value must lie in the range [-1,1] , with 1 indicating perfect correlation and −1 indicating perfect anti-correlation. For jointly wide-sense stationary stochastic processes, the definition is \rho_{XY}(\tau) = \frac{\operatorname{K}_{XY}(\tau)}{\sigma_X \sigma_Y} = \frac{\operatorname{E}\left[\overline{\left(X_t - \mu_X\right)} \left(Y_{t+\tau} - \mu_Y\right)\right]}{\sigma_X \sigma_Y} 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: \operatorname{R}_{XY}(t_1, t_2) = \overline{\operatorname{R}_{YX}(t_2, t_1)} Respectively for jointly WSS processes: \operatorname{R}_{XY}(\tau) = \overline{\operatorname{R}_{YX}(-\tau)} ==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. 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 \tau_\mathrm{delay}=\underset{t \in \mathbb{R}}{\operatorname{arg\,max}}((f \star g)(t)) ==Terminology in image processing== ===Zero-normalized cross-correlation (ZNCC)=== 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 t(x,y) with a subimage f(x,y) is \frac{1}{n\sigma_f \sigma_t} \sum_{x,y}\left(f(x,y) - \mu_f \right)\left(t(x,y) - \mu_t \right) where n is the number of pixels in t(x,y) and f(x,y) , \mu_f is the average of f and \sigma_f is standard deviation of f . In functional analysis terms, this can be thought of as the dot product of two normalized vectors. That is, if F(x,y) = f(x,y) - \mu_f and T(x,y) = t(x,y) - \mu_t then the above sum is equal to \left\langle\frac{F}{\|F\|},\frac{T}{\|T\|}\right\rangle where \langle\cdot,\cdot\rangle is the inner product and \|\cdot\| is the L² norm. Cauchy–Schwarz then implies that ZNCC has a range of [-1, 1] . Thus, if f and t are real matrices, their normalized cross-correlation equals the cosine of the angle between the unit vectors F and T , being thus 1 if and only if F equals T 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: \frac{1}{n\sigma_f \sigma_t} \sum_{x,y}f(x,y) t(x,y) ==See also== Autocorrelation Autocovariance Coherence Convolution Correlation Correlation function Cross-correlation matrix Cross-covariance Cross-spectrum Digital image correlation Phase correlation Scaled correlation Spectral density Wiener–Khinchin theorem ==References== ==Further reading== ==External links== Cross Correlation from Mathworld http://scribblethink.org/Work/nvisionInterface/nip.html http://www.staff.ncl.ac.uk/oliver.hinton/eee305/Chapter6.pdf
Text derived from https://en.wikipedia.org/w/index.php?oldid=1364956352 under CC BY-SA 4.0; modifications have been made.