Autocorrelation Calculator

Introduction to autocorrelation and time-series lag analysis

This autocorrelation calculator helps you test whether an ordered numeric series carries memory from one observation to the next. Instead of comparing two different variables, autocorrelation compares the series with itself after a delay. If the delayed copy still lines up in a meaningful way, the data may be showing persistence, repetition, seasonality, reversal, or some other kind of serial structure. The page is built for practical use: paste a sequence, choose a maximum lag, and read the resulting coefficients as a plain-language clue about what kind of dependence may be present.

The autocorrelation function, usually called the ACF, starts with an ordered sequence such as [x0,x1,,xn-1] and asks how similar it is to itself after a shift of k time steps. When the coefficient is near 1, later values tend to move with earlier values in the same direction. When it is near -1, the series tends to flip direction after that delay. Values around zero suggest little linear similarity at the selected lag, even though nonlinear dependence can still exist.

Before any lag comparison is made, the calculator centers the data around their mean so that the result reflects pattern rather than absolute level. In other words, the tool first computes x¯=1nt=0n-1xt and then measures how the deviations from that average line up after a shift. That centering step matters because a series with a high average but no meaningful pattern should not look correlated merely because its values are far from zero.

In practice, an ACF table is often one of the first diagnostic views analysts inspect when they receive time-series data. Monthly sales, daily temperatures, hourly website sessions, minute-by-minute machine readings, and even laboratory observations can all be explored this way as long as order matters. A smooth decline across the first few lags can suggest persistence. Alternating positive and negative values can suggest oscillation. Sharp spikes at fixed intervals often hint at seasonality or repeated cycles. The calculator does not replace full modeling, but it gives you a fast statistical map of where the structure may live.

How to use this autocorrelation calculator with ordered time-series data

This autocorrelation calculator works best when you enter the series exactly in time order and choose a lag range that matches the question you are asking. Paste the observations as a comma-separated list, type the largest lag you want to inspect, and click Compute ACF. The script trims extra spaces, reads the numeric values, calculates the sample mean, and returns one autocorrelation coefficient for each lag up to your chosen limit. Because each lag requires valid pairs such as (xt,xt-k), the calculation only makes sense while k<n, and the page automatically stops before the lag reaches the series length.

The data box is for the actual observed series. Do not sort the values from smallest to largest, because autocorrelation is about sequence, not just size. If you are analyzing monthly demand, list the months in order. If you are evaluating sensor readings, use the measurement order the device produced. The lag field plays a different role: it defines how far out you want to compare the series with its delayed copies. Small lag limits are useful when you care about short-run carryover, while larger ones are helpful when you suspect longer cycles or seasonality.

After the table appears, read each row as a statement about repetition over time. A large positive lag-1 value means adjacent observations tend to move together. A large negative lag-1 value suggests a back-and-forth pattern from one step to the next. If lag 7 stands out in daily data, a weekly rhythm may be present. If lag 12 stands out in monthly data, a yearly seasonal effect becomes plausible. This calculator does not run model selection for you, and it does not perform a full hypothesis test, but it gives you a clear numerical starting point for further diagnosis.

Autocorrelation tables are also easiest to trust when you keep sample size in mind. The first few lags are usually the most stable because they use many overlapping pairs. Long lags are noisier because fewer pairs remain after shifting the series. A near-zero coefficient therefore means only that the linear relationship at that specific lag is weak in the available sample; it does not prove the series is random or free from all dependence. Treat the output as evidence to interpret, not as a single final verdict.

The autocorrelation formula and how to interpret each lag

The autocorrelation formula used by this calculator is the standard sample ACF coefficient at lag k:

Formula: r_k = (∑ t = k n - 1 (x_t - x ¯) (x_t-k - x ¯)) / (∑ t = 0 n - 1 (x_t-x¯)^2)

rk=t=kn-1(xt-x¯)(xt-k-x¯)t=0n-1(xt-x¯)2

Here x¯ is the sample mean. The numerator measures how well the series aligns with a delayed copy of itself at lag k. The denominator rescales that comparison by the total variation in the original data, which keeps the result on a familiar range between about -1 and 1. Without that normalization, large-valued series would naturally produce larger raw sums even if their underlying patterns were no more regular than small-valued series.

Another way to describe the same idea is to start with the lagged covariance estimate ck=t=kn-1(xt-x¯)(xt-k-x¯). Autocorrelation is that covariance divided by the lag-0 variance term. This normalization is why coefficients at different lags are easy to compare visually and numerically in the table generated by the calculator.

In probability language, the sample formula is approximating the theoretical autocorrelation function of a weakly stationary process. If Xt has mean μ and covariance function γ(k), then the population ACF is ρ(k)=γ(k)γ(0). That definition forces ρ(0)=1 and keeps -1ρ(k)1 for each lag k. As the sample size n grows, the sample ACF usually becomes a better guide to the underlying process, provided the stationarity and ergodicity assumptions are at least roughly reasonable.

Different books and software packages sometimes use slightly different finite-sample conventions. This calculator uses all n centered observations in the denominator, which is common and easy to interpret. Some references discuss a lag-specific scaling based on n-k in the covariance term. Those choices can create small numerical differences, especially at long lags in short samples, so it is worth checking definitions when you compare results across tools.

Analysts often pair the ACF with rough significance guidance. For a white-noise series, nonzero sample autocorrelations often stay within approximate 95% bounds of ±1.96n. That rule is only a heuristic, not a complete test, but it is useful when you want a quick sense of whether a coefficient is unusually large relative to the amount of data available.

Worked example: computing ACF for a 7-point sample series

This worked example uses a short seven-point time series so you can see exactly how the autocorrelation calculator builds one lag coefficient. Suppose your data are [4,8,6,5,3,2,4]. The sample mean is 327, so the first step is to compute the total centered variation in the denominator:

Formula: ∑ t = 0 6 (x_t-32/7)^2 = 20.5714

t=06(xt-327)2=20.5714

Now take lag 1. Each value is paired with the previous value, and the numerator becomes

Formula: ∑ t = 1 6 (x_t - 32 / 7) (x_t-1 - 32 / 7) = 8.2857

t=16(xt-327)(xt-1-327)=8.2857

Dividing the numerator by the denominator gives an autocorrelation of about 0.403. That is a moderate positive relationship, which means adjacent observations in this sample tend to move together more often than not. It is not a perfect match, but it is clearly not random noise either. For comparison, the lag-0 value is always r0=1 because a series matches itself perfectly when there is no shift at all.

Sample autocorrelation values for the example series.
Lag Autocorrelation
1 0.403
2 -0.138
3 -0.601

The negative value at lag 3 is especially informative. It says that once the series is shifted by three time steps, higher values tend to line up with lower values and lower values tend to line up with higher ones. That is the signature of reversal or oscillation rather than persistence. Seeing both positive and negative lags in the same table is one reason autocorrelation is such a rich descriptive tool. If you paste these same seven values into the calculator above and request at least three lags, you should see a matching pattern up to rounding.

How analysts use ACF in forecasting and residual diagnostics

In real time-series analysis, autocorrelation often acts as a bridge between raw data and model choice. In autoregressive settings, the shape of the ACF can point toward a simple dependence structure. For example, an AR(1) process often has a population pattern like ρ(k)=φk, which creates a steady geometric decay across lags. That looks very different from the repeating spikes you might see in seasonal data, where a seasonal lag such as s becomes the natural point of comparison.

Residual checking is another major use. After fitting a forecasting model, analysts inspect residual autocorrelation to see whether the model has left systematic structure behind. If the residuals behave roughly like white noise εt, then the model has captured much of the predictable pattern. If not, the leftover structure often suggests missing lags, unremoved seasonality, a poor trend adjustment, or a model form that is too simple for the data.

The idea also appears in familiar summary statistics. The Durbin–Watson statistic for regression residuals is closely related to lag-1 autocorrelation through 2(1-ρ(1)). Signal processing, communications, climatology, manufacturing, and finance all use ACF for slightly different reasons, but the core question is the same in every field: when the series is shifted, does the pattern still resemble itself?

Limitations of sample autocorrelation estimates and stationarity assumptions

These limitations matter whenever you interpret sample autocorrelation, because a strong ACF can come from trend, seasonality, or changing variance instead of true short-run dependence. Autocorrelation works best when comparing one part of the series with another is genuinely meaningful. If the mean is drifting upward, the variance is expanding, or there is a large deterministic trend, the ACF can look strong even when the real issue is nonstationarity rather than repeated local dependence. Detrending, differencing, or seasonal adjustment can make the ACF far more informative in those settings, which is why analysts usually treat the ACF as an exploratory lens instead of a one-number verdict.

The coefficient is also linear by design. A near-zero value does not eliminate the possibility of threshold effects, nonlinear dynamics, structural breaks, or rare regime changes. Long lags deserve extra caution because they are estimated from fewer overlaps. That practical sample-size constraint is built into the indexing itself: you need enough data so that k<n remains comfortably true, not just barely true. When the sample is short, the outer part of the ACF table should be read with restraint.

Another limitation is that significance rules are often approximate. The common white-noise band ±1.96n can be useful for quick screening, but it is not a substitute for a model-based diagnostic test, especially when the data are heteroskedastic, seasonal, or already filtered through another estimation step. In other words, a visually large autocorrelation may still require context before you call it meaningful, and a visually small one does not automatically clear a model of all problems.

Finally, some data sets produce clear edge cases. If every observation is identical, there is no variation to scale by, and the variance term collapses to t=0n-1(xt-x¯)2=0. In that case, autocorrelation is not meaningfully defined because the denominator is zero. For ordinary data with variation, though, the calculator gives a fast, private, client-side way to connect the formula to actual numbers and to build intuition before moving into deeper time-series modeling.

Use commas between numbers and keep the observations in time order. Spaces are fine. Example: 4, 8, 6, 5, 3, 2, 4

Choose the largest lag to compute. The script will stop automatically before the lag reaches the series length.

This calculator accepts integers, decimals, and negative values. It computes sample autocorrelation on the numbers you enter in the browser and does not upload the series anywhere from this page.

Results will appear here after you compute the autocorrelation table.

Lag Lock mini-game for autocorrelation intuition

This optional mini-game turns autocorrelation into a fast visual challenge. The top track shows a source signal and the bottom track shows a delayed copy. Your job is to drag the lag ruler to shift the lower signal and then lock in the lag that best fits the round mission. Early rounds reward the strongest positive autocorrelation, where peaks line up with peaks. Later rounds add negative-autocorrelation missions, where the best answer is the lag that creates the strongest opposite-direction alignment. The calculator above stays completely separate; the game is only for intuition and replayable practice.

Score0
Time75s
Streak0
Round1
Best0

Start the lag alignment challenge

Mission: drag the lag ruler to slide the echo signal, then tap the waveform or press Space to lock your answer. Score big by finding the strongest match before the timer expires. Later rounds introduce negative-autocorrelation hunts and shorter lock windows.

Best score on this device: 0

Educational takeaway: the best-scoring lag is the shift where the series most strongly resembles its own delayed copy.

Controls are designed for both pointer and keyboard input. On desktop or mobile, drag the ruler at the bottom of the canvas to change the lag. Then tap or click the waveform area to lock your guess. With a keyboard, use the left and right arrow keys to move the lag handle and press Space or Enter to submit. A visible HUD tracks score, time, streak, round, and best score saved on your device for replay value.

Embed this calculator

Copy and paste the HTML below to add the Autocorrelation Calculator (ACF) | Time Series Lag Analysis to your website.