Calculates on this device. File exports run online.
Cross Correlation Calculator
Type two sequences of numbers to get their cross-correlation at every lag, the lag where they match best (with a sub-sample estimate), and the delay in seconds when you give the sample rate. Choose raw sums, values normalised to 1 for a perfect match, or correlation coefficients with the means removed.
Enter your values
Check these values
Your values are worked out in this browser. They are not sent to a server.
Your result will show here
Fill in the values, then choose Calculate.
Your result
How it was worked out
How to use the cross correlation calculator
- Type the samples of x and y, separated by commas or spaces.
- Choose the scale: normalised (1 for a perfect match), correlation coefficient (offsets removed) or raw sums.
- Under More options give the sample rate to get the delay in seconds.
- The box under the result works it out again on the server and draws it.
The formulas
- c[k] = Σ x[n + k] y[n], for lags k from −(Ly − 1) to Lx − 1 (as numpy.correlate). A peak at lag k means x matches y shifted k samples later.
- Normalised: c[k] ÷ √(Σx² Σy²). Correlation coefficient: the same with the means taken away first.
- Circular: r[k] = Σ x[(n + k) mod N] y[n]; its DFT is X[k] × conj(Y[k]) (the correlation theorem).
Worked example
x = 0, 0, 1, 3, 1, 0, 0, 0 and y = 1, 3, 1, 0, 0, 0, 0, 0 match perfectly at lag 2 (normalised correlation 1): x is y delayed by two samples, 2 ms at 1 kHz. At lag 0 the normalised correlation is only 0.091.
Limits you should know
- Real numbers only, up to 5,000 samples (2,048 for circular). The ends of the lag range overlap few samples, so their values rest on little data.