This example shows how to create confidence intervals for the autocorrelation sequence of a white noise process. Create a realization of a white noise process 1,000 samples in length. Compute the sample autocorrelation to lag 20. Plot the sample autocorrelation along with the approximate 95%-confidence intervals for a white noise process.
Create the white noise random vector. Set the random number generator to the default settings for reproducible results. Obtain the normalized sampled autocorrelation to lag 20.
rng default; x = randn(1e3,1); [xc,lags] = xcorr(x,20,'coeff');
Create the lower and upper 95% confidence bounds for the N(0,1/N) distribution. For a 95%-confidence interval, the critical value is 1.96. The standard deviation is the square root of 1/N, where N is the length of the input vector.
The confidence interval is
lconf = -1.96/sqrt(length(x)); upconf = 1.96/sqrt(length(x));
Plot the sample autocorrelation along with the 95%-confidence interval.
stem(lags,xc,'markerfacecolor',[0 0 1]); set(gca,'ylim',[lconf-0.03 1.05]); hold on; line(lags,lconf*ones(size(lags)),'color','r','linewidth',2); line(lags,upconf*ones(size(lags)),'color','r','linewidth',2); title('Sample Autocorrelation with 95% Confidence Intervals');
You see in the above figure that the only autocorrelation value outside of the 95%-confidence interval occurs at lag 0 as expected for a white noise process. Based on this result, you can conclude that the data are a realization of a white noise process.