Toolvito

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

Your values

Numbers separated by commas or spaces.

To find the delay of x behind y, or the lag where they match best.

More options

Optional: gives the delay in seconds.

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.

Correlation checked on the server

Correlation checked on the server

Uses the signals above. The server works the correlation out again with numpy.correlate and SciPy’s lags (checked by an FFT), or the circular correlation by the FFT, and draws it.

The calculator above works on your device. When you run a task in this section, Toolvito receives the values and result you submit to make the file or run the check. Download the result within one hour after the job finishes. Choose Delete files now to request earlier removal. The hourly cleanup normally removes files within one to two hours after completion.

How to use the cross correlation calculator

  1. Type the samples of x and y, separated by commas or spaces.
  2. Choose the scale: normalised (1 for a perfect match), correlation coefficient (offsets removed) or raw sums.
  3. Under More options give the sample rate to get the delay in seconds.
  4. 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.

Related tools