Cross-correlation

Last updated
Visual comparison of convolution, cross-correlation and autocorrelation. For the operations involving function f, and assuming the height of f 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 f is the reason
f
*
g
{\displaystyle f*g}
and
f
[?]
g
{\displaystyle f\star g}
are identical in this example. Comparison convolution correlation.svg
Visual comparison of convolution, cross-correlation and autocorrelation. For the operations involving function f, and assuming the height of f 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 f is the reason and 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.

Contents

In probability and statistics, the term cross-correlations refers to the correlations between the entries of two random vectors and , while the correlations of a random vector are the correlations between the entries of itself, those forming the correlation matrix of . If each of and is a scalar random variable which is realized repeatedly in a time series, then the correlations of the various temporal instances of are known as autocorrelations of , and the cross-correlations of with 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 and are two independent random variables with probability density functions and , respectively, then the probability density of the difference is formally given by the cross-correlation (in the signal-processing sense) ; however, this terminology is not used in probability and statistics. In contrast, the convolution (equivalent to the cross-correlation of and ) gives the probability density function of the sum .

Cross-correlation of deterministic signals

For continuous functions and , the cross-correlation is defined as: [1] [2] [3]

 

 

 

 

(Eq.1)

which is equivalent to

where denotes the complex conjugate of , and is called displacement or lag. For highly-correlated and which have a maximum cross-correlation at a particular , a feature in at also occurs later in at , hence could be described to lag by .

If and are both continuous periodic functions of period , the integration from to is replaced by integration over any interval of length :

 

 

 

 

(Eq.2)

which is equivalent to

Similarly, for discrete functions, the cross-correlation is defined as: [4] [5]

 

 

 

 

(Eq.3)

which is equivalent to

.

For finite discrete functions , the (circular) cross-correlation is defined as: [6]

 

 

 

 

(Eq.4)

which is equivalent to

.

For finite discrete functions , , the kernel cross-correlation is defined as: [7]

 

 

 

 

(Eq.5)

where is a vector of kernel functions and is an affine transform.

Specifically, 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 and differing only by an unknown shift along the x-axis. One can use the cross-correlation to find how much must be shifted along the x-axis to make it identical to . The formula essentially slides the function along the x-axis, calculating the integral of their product at each position. When the functions match, the value of 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.

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 . 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 and , taking the conjugate of 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] :p. 74

Properties

  • The cross-correlation of functions and is equivalent to the convolution (denoted by ) of and . That is:
  • If is a Hermitian function, then
  • If both and are Hermitian, then .
  • .
  • Analogous to the convolution theorem, the cross-correlation satisfies
    where denotes the Fourier transform, and an again indicates the complex conjugate of , since . 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 and with a function is the convolution of the cross-correlation of and with the kernel :
    .

Cross-correlation of random vectors

Definition

For random vectors and , each containing random elements whose expected value and variance exist, the cross-correlation matrix of and is defined by [10] :p.337

 

 

 

 

(Eq.6)

and has dimensions . Written component-wise:

The random vectors and need not have the same dimension, and either might be a scalar value.

Example

For example, if and are random vectors, then is a matrix whose -th entry is .

Definition for complex random vectors

If and are complex random vectors, each containing random variables whose expected value and variance exist, the cross-correlation matrix of and is defined by

where 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 be a pair of random processes, and be any point in time ( may be an integer for a discrete-time process or a real number for a continuous-time process). Then is the value (or realization) produced by a given run of the process at time .

Cross-correlation function

Suppose that the process has means and and variances and at time , for each . Then the definition of the cross-correlation between times and is [10] :p.392

 

 

 

 

(Eq.7)

where 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 and : [10] :p.392

 

 

 

 

(Eq.8)

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 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

 

 

 

 

(Eq.9)

or equivalently

Cross-covariance function

 

 

 

 

(Eq.10)

or equivalently

where and are the mean and standard deviation of the process , which are constant over time due to stationarity; and similarly for , respectively. indicates the expected value. That the cross-covariance and cross-correlation are independent of is precisely the additional information (beyond being individually wide-sense stationary) conveyed by the requirement that 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

.

If the function is well-defined, its value must lie in the range , with 1 indicating perfect correlation and −1 indicating perfect anti-correlation.

For jointly wide-sense stationary stochastic processes, the definition is

.

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] :p.173

Respectively for jointly WSS processes:

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] [ clarification needed ] 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

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. Cross Correlation Animation.gif
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 with a subimage is

where is the number of pixels in and , is the average of and is standard deviation of .

In functional analysis terms, this can be thought of as the dot product of two normalized vectors. That is, if

and

then the above sum is equal to

where is the inner product and is the L² norm. Cauchy–Schwarz then implies that ZNCC has a range of .

Thus, if and are real matrices, their normalized cross-correlation equals the cosine of the angle between the unit vectors and , being thus if and only if equals multiplied by a positive scalar.

Normalized correlation is one of the methods used for template matching, a process used for finding incidences 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:

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

Related Research Articles

Autocorrelation Correlation of a signal with a time-shifted copy of itself, as a function of shift

Autocorrelation, sometimes known as serial correlation in the discrete time case, is the correlation of a signal with a delayed copy of itself as a function of delay. Informally, it is the similarity between observations as a function of the time lag between them. The analysis of autocorrelation is a mathematical tool for finding repeating patterns, such as the presence of a periodic signal obscured by noise, or identifying the missing fundamental frequency in a signal implied by its harmonic frequencies. It is often used in signal processing for analyzing functions or series of values, such as time domain signals.

Convolution Binary mathematical operation on functions

In mathematics, convolution is a mathematical operation on two functions that produces a third function that expresses how the shape of one is modified by the other. The term convolution refers to both the result function and to the process of computing it. It is defined as the integral of the product of the two functions after one is reversed and shifted. The integral is evaluated for all values of shift, producing the convolution function.

Normal distribution Probability distribution

In statistics, a normal distribution is a type of continuous probability distribution for a real-valued random variable. The general form of its probability density function is

Variance Statistical measure of how far values spread from their average

In probability theory and statistics, variance is the expectation of the squared deviation of a random variable from its population mean or sample mean. Variance is a measure of dispersion, meaning it is a measure of how far a set of numbers is spread out from their average value. Variance has a central role in statistics, where some ideas that use it include descriptive statistics, statistical inference, hypothesis testing, goodness of fit, and Monte Carlo sampling. Variance is an important tool in the sciences, where statistical analysis of data is common. The variance is the square of the standard deviation, the second central moment of a distribution, and the covariance of the random variable with itself, and it is often represented by , , , , or .

Multivariate normal distribution Generalization of the one-dimensional normal distribution to higher dimensions

In probability theory and statistics, the multivariate normal distribution, multivariate Gaussian distribution, or joint normal distribution is a generalization of the one-dimensional (univariate) normal distribution to higher dimensions. One definition is that a random vector is said to be k-variate normally distributed if every linear combination of its k components has a univariate normal distribution. Its importance derives mainly from the multivariate central limit theorem. The multivariate normal distribution is often used to describe, at least approximately, any set of (possibly) correlated real-valued random variables each of which clusters around a mean value.

In probability theory and statistics, covariance is a measure of the joint variability of two random variables. If the greater values of one variable mainly correspond with the greater values of the other variable, and the same holds for the lesser values, the covariance is positive. In the opposite case, when the greater values of one variable mainly correspond to the lesser values of the other,, the covariance is negative. The sign of the covariance therefore shows the tendency in the linear relationship between the variables. The magnitude of the covariance is not easy to interpret because it is not normalized and hence depends on the magnitudes of the variables. The normalized version of the covariance, the correlation coefficient, however, shows by its magnitude the strength of the linear relation.

Covariance matrix Measure of covariance of components of a random vector

In probability theory and statistics, a covariance matrix is a square matrix giving the covariance between each pair of elements of a given random vector. Any covariance matrix is symmetric and positive semi-definite and its main diagonal contains variances.

Expectation–maximization algorithm Iterative method for finding maximum likelihood estimates in statistical models

In statistics, an expectation–maximization (EM) algorithm is an iterative method to find (local) maximum likelihood or maximum a posteriori (MAP) estimates of parameters in statistical models, where the model depends on unobserved latent variables. The EM iteration alternates between performing an expectation (E) step, which creates a function for the expectation of the log-likelihood evaluated using the current estimate for the parameters, and a maximization (M) step, which computes parameters maximizing the expected log-likelihood found on the E step. These parameter-estimates are then used to determine the distribution of the latent variables in the next E step.

In physics, the Hamilton–Jacobi equation, named after William Rowan Hamilton and Carl Gustav Jacob Jacobi, is an alternative formulation of classical mechanics, equivalent to other formulations such as Newton's laws of motion, Lagrangian mechanics and Hamiltonian mechanics. The Hamilton–Jacobi equation is particularly useful in identifying conserved quantities for mechanical systems, which may be possible even when the mechanical problem itself cannot be solved completely.

Hotellings <i>T</i>-squared distribution

In statistics, particularly in hypothesis testing, the Hotelling's T-squared distribution (T2), proposed by Harold Hotelling, is a multivariate probability distribution that is tightly related to the F-distribution and is most notable for arising as the distribution of a set of sample statistics that are natural generalizations of the statistics underlying the Student's t-distribution. The Hotelling's t-squared statistic (t2) is a generalization of Student's t-statistic that is used in multivariate hypothesis testing.

In statistics, sometimes the covariance matrix of a multivariate random variable is not known but has to be estimated. Estimation of covariance matrices then deals with the question of how to approximate the actual covariance matrix on the basis of a sample from the multivariate distribution. Simple cases, where observations are complete, can be dealt with by using the sample covariance matrix. The sample covariance matrix (SCM) is an unbiased and efficient estimator of the covariance matrix if the space of covariance matrices is viewed as an extrinsic convex cone in Rp×p; however, measured using the intrinsic geometry of positive-definite matrices, the SCM is a biased and inefficient estimator. In addition, if the random variable has a normal distribution, the sample covariance matrix has a Wishart distribution and a slightly differently scaled version of it is the maximum likelihood estimate. Cases involving missing data require deeper considerations. Another issue is the robustness to outliers, to which sample covariance matrices are highly sensitive.

In probability theory and statistics, given a stochastic process, the autocovariance is a function that gives the covariance of the process with itself at pairs of time points. Autocovariance is closely related to the autocorrelation of the process in question.

In probability and statistics, given two stochastic processes and , the cross-covariance is a function that gives the covariance of one process with the other at pairs of time points. With the usual notation for the expectation operator, if the processes have the mean functions and , then the cross-covariance is given by

Elliptic coordinate system

In geometry, the elliptic coordinate system is a two-dimensional orthogonal coordinate system in which the coordinate lines are confocal ellipses and hyperbolae. The two foci and are generally taken to be fixed at and , respectively, on the -axis of the Cartesian coordinate system.

Toroidal coordinates

Toroidal coordinates are a three-dimensional orthogonal coordinate system that results from rotating the two-dimensional bipolar coordinate system about the axis that separates its two foci. Thus, the two foci and in bipolar coordinates become a ring of radius in the plane of the toroidal coordinate system; the -axis is the axis of rotation. The focal ring is also known as the reference circle.

Elliptic cylindrical coordinates

Elliptic cylindrical coordinates are a three-dimensional orthogonal coordinate system that results from projecting the two-dimensional elliptic coordinate system in the perpendicular -direction. Hence, the coordinate surfaces are prisms of confocal ellipses and hyperbolae. The two foci and are generally taken to be fixed at and , respectively, on the -axis of the Cartesian coordinate system.

Oblate spheroidal coordinates Three-dimensional orthogonal coordinate system

Oblate spheroidal coordinates are a three-dimensional orthogonal coordinate system that results from rotating the two-dimensional elliptic coordinate system about the non-focal axis of the ellipse, i.e., the symmetry axis that separates the foci. Thus, the two foci are transformed into a ring of radius in the x-y plane. Oblate spheroidal coordinates can also be considered as a limiting case of ellipsoidal coordinates in which the two largest semi-axes are equal in length.

The intent of this article is to highlight the important points of the derivation of the Navier–Stokes equations as well as its application and formulation for different families of fluids.

In probability theory and statistics, the normal-gamma distribution is a bivariate four-parameter family of continuous probability distributions. It is the conjugate prior of a normal distribution with unknown mean and precision.

In statistical mechanics, the Griffiths inequality, sometimes also called Griffiths–Kelly–Sherman inequality or GKS inequality, named after Robert B. Griffiths, is a correlation inequality for ferromagnetic spin systems. Informally, it says that in ferromagnetic spin systems, if the 'a-priori distribution' of the spin is invariant under spin flipping, the correlation of any monomial of the spins is non-negative; and the two point correlation of two monomial of the spins is non-negative.

References

  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. Rabiner, L.R.; Schafer, R.W. (1978). Digital Processing of Speech Signals . Signal Processing Series. Upper Saddle River, NJ: Prentice Hall. pp.  147–148. ISBN   0132136031.
  5. Rabiner, Lawrence R.; Gold, Bernard (1975). Theory and Application of Digital Signal Processing . Englewood Cliffs, NJ: Prentice-Hall. pp.  401. ISBN   0139141014.
  6. Wang, Chen (2019). Kernel learning for visual perception, Chapter 2.2.1. Doctoral thesis. Nanyang Technological University, Singapore. pp.  17–18.
  7. Wang, Chen; Zhang, Le; Yuan, Junsong; Xie, Lihua (2018). Kernel Cross-Correlator. The Thirty-second AAAI Conference On Artificial Intelligence. Association for the Advancement of Artificial Intelligence. pp. 4179–4186.
  8. Campbell; Lo; MacKinlay (1996). The Econometrics of Financial Markets. NJ: Princeton University Press. ISBN   0691043019.
  9. Kapinchev, Konstantin; Bradu, Adrian; Barnes, Frederick; Podoleanu, Adrian (2015). "GPU implementation of cross-correlation for image generation in real time". 2015 9th International Conference on Signal Processing and Communication Systems (ICSPCS). pp. 1–6. doi:10.1109/ICSPCS.2015.7391783. ISBN   978-1-4673-8118-5.
  10. 1 2 3 Gubner, John A. (2006). Probability and Random Processes for Electrical and Computer Engineers. Cambridge University Press. ISBN   978-0-521-86470-1.
  11. Kun Il Park, Fundamentals of Probability and Stochastic Processes with Applications to Communications, Springer, 2018, 978-3-319-68074-3
  12. Rhudy, Matthew; Brian Bucci; Jeffrey Vipperman; Jeffrey Allanach; Bruce Abraham (November 2009). Microphone Array Analysis Methods Using Cross-Correlations. Proceedings of 2009 ASME International Mechanical Engineering Congress, Lake Buena Vista, FL. pp. 281–288. doi:10.1115/IMECE2009-10798. ISBN   978-0-7918-4388-8.
  13. Rhudy, Matthew (November 2009). "Real Time Implementation of a Military Impulse Classifier". University of Pittsburgh, Master's Thesis.{{cite journal}}: Cite journal requires |journal= (help)
  14. Billings, S. A. (2013). Nonlinear System Identification: NARMAX Methods in the Time, Frequency, and Spatio-Temporal Domains. Wiley. ISBN   978-1-118-53556-1.

Further reading