dcorr

Cross correlation function using discrete Fourier Transforms (dFT).

Syntax

dcorr(vec_expr_1, vec_expr_2)

Argument

vec_expr_1, vec_expr_2
A pair of valid vector expressions.

Example

Curve Math Vectors Result
x = 0:(numpts(c1.y)-1):1

y = dcorr(c1.y, c2.y)

Given c1 and c2, a curve is created which is the cross-correlation between the y vectors of c1 and c2.

Comments

The dcorr function uses discrete Fourier Transforms to calculate cross-correlations, defined as:



vec_expr_1 and vec_expr_2 must be vectors, and they must have the same number of points. The result is a vector with the same number of points as vec_expr_1. The elements of the result are the normalized, biased correlations between vec_expr_1 and vec_expr_2 at the corresponding lag.

If the same vector is given as vec_expr_1 and vec_expr_2, the result is the autocorrelation function for that vector. The two vectors are said to be completely correlated at a given lag if the correlation function at that lag is one. They are said to be uncorrelated if the value is zero.

A typical x vector for plotting a cross-correlation curve is shown below:

0 : (numpts(vec_expr_1)-1) : 1

This method is more accurate than fcorr, but much slower, especially with large numbers of points.