GestureSynth.me

Music calculator

Autocorrelation Calculator

Calculate finite real-signal autocorrelation at every nonnegative lag. Compare a raw product sum with full-length and overlap-based normalization.

autocorrelation calculator

Autocorrelation Calculator guide

Autocorrelation compares a record with shifted copies of itself. Enter real samples in time order and choose the lag whose value should appear in the headline. The table still shows all supported nonnegative lags so that a single selected value can be interpreted alongside its neighbors and the zero-lag energy.

Play the instrument ↑
Default result
-2 at lag 2

Calculation and units

At lag k, multiply sample j by sample j plus k and sum over all overlapping pairs. No values wrap around the ends. Raw mode returns this sum. Full-length normalization divides it by N and overlap normalization divides it by N minus k. At zero lag the raw value is the sum of squared samples.

Worked examples

Select a named case in the Worked example control to load these values. You can then edit any input to compare the result.

Alternating pulse train

Input sequence = 1 0 -1 0 1 · Lag to inspect (samples) = 2 · Normalization = Raw sum.

-2 at lag 2. Lag zero 3. Selected overlap 3 sample pairs. Input mean retained. Negative lags mirror positive lags for a real sequence. Table readings (Lag, Correlation): 0, 3; 1, 0; 2, -2; 3, 0; 4, 1.

At lag two the nonzero overlapping products have opposite signs. Inspect the row at zero lag to compare against the record energy.

Zero lag energy

Input sequence = 1 2 3 · Lag to inspect (samples) = 0 · Normalization = Raw sum.

14 at lag 0. Lag zero 14. Selected overlap 3 sample pairs. Input mean retained. Negative lags mirror positive lags for a real sequence. Table readings (Lag, Correlation): 0, 14; 1, 8; 2, 3.

At zero lag each sample multiplies itself. The sum of the three squares is a useful reference before interpreting any shifted result.

Full length normalization

Input sequence = 1 2 3 · Lag to inspect (samples) = 1 · Normalization = Divide by full length.

2.6666667 at lag 1. Lag zero 4.6666667. Selected overlap 2 sample pairs. Input mean retained. Negative lags mirror positive lags for a real sequence. Table readings (Lag, Correlation): 0, 4.6666667; 1, 2.6666667; 2, 1.

The overlap products sum to eight. Dividing by three uses the same divisor at every lag, including those with only one surviving pair.

Overlap normalization

Input sequence = 1 2 3 · Lag to inspect (samples) = 1 · Normalization = Divide by overlap.

4 at lag 1. Lag zero 4.6666667. Selected overlap 2 sample pairs. Input mean retained. Negative lags mirror positive lags for a real sequence. Table readings (Lag, Correlation): 0, 4.6666667; 1, 4; 2, 3.

The same two overlapping products now share a divisor of two. The change in scale is entirely due to the selected normalization.

Largest supported lag

Input sequence = 2 -1 3 4 · Lag to inspect (samples) = 3 · Normalization = Raw sum.

8 at lag 3. Lag zero 30. Selected overlap 1 sample pairs. Input mean retained. Negative lags mirror positive lags for a real sequence. Table readings (Lag, Correlation): 0, 30; 1, 7; 2, 2; 3, 8.

Only the first and last sample overlap. A large value in this row has less supporting data than the central correlation values.

Constant input retained

Input sequence = 2 2 2 2 · Lag to inspect (samples) = 2 · Normalization = Divide by overlap.

4 at lag 2. Lag zero 4. Selected overlap 2 sample pairs. Input mean retained. Negative lags mirror positive lags for a real sequence. Table readings (Lag, Correlation): 0, 4; 1, 4; 2, 4; 3, 4.

A constant sequence has a nonzero result because the mean is retained. Subtract the sample average first to study deviations around an offset.

Interpreting the result

A positive peak away from zero can indicate recurring structure at a corresponding sample separation. Convert the lag to seconds by dividing by the original sample rate. Look for repeated peaks with enough supporting pairs before interpreting a period. A very short overlap can produce a large normalized number that does not recur elsewhere in the record.

Measurement and model limits

The input mean is retained, so a constant offset can dominate the result. Subtract the mean separately when the aim is an autocovariance of deviations. This implementation handles finite real data. A complex sequence requires conjugation, and a circular correlation uses a different edge convention. Neither should be compared directly with these table entries.

Answers before you play

Common questions

Are negative lags available?

For a real sequence the autocorrelation is symmetric about zero lag under these conventions. Read the corresponding positive-lag row when considering its negative counterpart.

Is the answer bounded by one?

These modes normalize by a count or leave the sum raw. They do not divide by the signal energy to force a unit zero-lag reference.

Why can a correlation be negative?

Negative products dominate when overlapping values tend to have opposite signs. This often happens around half a period for alternating signals with little offset.

How do I handle a lag longer than the input?

Select a lag below the sample count. At the last valid lag only the first and last values overlap, and beyond it there are no observed pairs.