Cross Correlation Calculator

Enter two sequences and a lag to get their cross-correlation.

Result

0.9937
7

How it is calculated

For a whole-number lag k the tool pairs xi with yi+k, using only the pairs where both values exist, and then computes the Pearson coefficient on those pairs: r = Σ(x − x̄)(y − ȳ) ÷ √(Σ(x − x̄)² × Σ(y − ȳ)²). A positive lag means Y is delayed relative to X, and a negative lag means Y comes earlier. The number of pairs is shown, and it shrinks as |lag| grows. Enter each series as numbers separated by spaces, commas, semicolons or tabs, with at least 2 values each; any non-numeric item, fewer than 2 pairs, or a series with no variation returns nothing. The lag is rounded to the nearest integer, and a blank lag counts as 0. The result is between −1 and 1 and is shown to four decimals.

Worked example

X = 2 5 3 8 4 7 6 9 and Y = 1 5 11 7 17 8 15 12, with lag 1. The pairs are (2,5), (5,11), (3,7), (8,17), (4,8), (7,15) and (6,12), so there are 7 pairs. Their means are 5 for X and about 10.71 for Y. The coefficient comes to 0.9937, which says Y follows X by one step almost perfectly. At lag 0 the same data give only 0.2204, so the delay is what reveals the relationship.

Try this example →

Common mistakes

  • Using decimal commas such as 2,5. A comma separates values, so 2,5 becomes the two numbers 2 and 5; use a decimal point.
  • Reading the sign of the lag backwards. Here a positive lag compares xi with the later value yi+k, so it tests whether Y lags behind X, not the reverse.
  • Using a large lag on short series. With 8 values and lag 6, only 2 pairs remain and the coefficient is almost always ±1 for no good reason; watch the pairs count.
  • Treating high correlation as proof that one series causes the other. It shows they move together after the shift, nothing more.

About this calculator

Cross-correlation measures how well two time series match up when one is shifted relative to the other by a chosen number of steps, or lag. This calculator computes the Pearson correlation coefficient between series X and a lagged version of series Y, testing whether values in one series tend to predict values in the other after accounting for a delay between them.

Signal processing engineers use cross-correlation to detect time delays between related signals (such as an echo or a sensor offset), while economists and time-series analysts use it to find lead-lag relationships between related data — for example, whether a change in one economic indicator tends to precede a change in another by a certain number of periods.

Was this helpful?

You can pick up to 3 reactions.

Comments

  • Be the first to comment.

Popular calculators

All Calculators