Sign in

username:

password:



Not a member?

Search Online Books



Search tips

Free Online Books

Ads

Chapters

See Also

Embedded SystemsFPGAElectronics
Chapter Contents:

Search Spectral Audio Signal Processing

  

Book Index | Global Index


Would you like to be notified by email when Julius Orion Smith III publishes a new entry into his blog?

  

Sample Autocorrelation

The sample autocorrelation of a sequence $ v(n)$, $ n=0,1,2,\ldots,N-1$ may be defined by

$\displaystyle \hat{r}_{v,N}(l) \isdef \frac{1}{N-\vert l\vert} \sum_{n=0}^{N-1}\overline{v(n)}v(n+l), \quad l=0,\pm1,\pm2, \ldots, \pm (N-1), \protect$ (6.1)

where $ v(n)$ is defined as zero outside of the range $ n\in[0,N-1]$. (Note that this differs from the usual definition of indexing modulo $ N$ for the DFT.) In more explicit detail, (5.1) can be written out as

$\displaystyle \left\{\begin{array}{ll} \frac{1}{N-l}\sum_{n=0}^{N-1-l}\overline...
...-1}\overline{v(n)}v(n+l), & l=-1,-2,\ldots,-N+1 \\ \end{array} \right. \protect$ (6.2)

and zero for $ \left\vert l\right\vert\geq N$.

In Matlab or Octave, the sample autocorrelation of a vector x can be computed using the xcorr function.6.3

Example:

octave:1> xcorr([1 1 1 1])
ans =
 
  1  2  3  4  3  2  1
The xcorr function also performs cross-correlation when given a second signal argument, and offers additional features with additional arguments. Say help xcorr for details.

Note that $ \hat{r}_{v,N}(l)$ is the average of the lagged product $ x(n)x(n+l)$ over all available data. For white noise, this average approaches zero for $ l\neq0$ as the number of terms in the average increases. That is, we must have

$\displaystyle \hat{r}_{v,N}(l) \approx \left\{\begin{array}{ll}
\hat{\sigma}_{v...
...5pt]
0, & l\neq
0 \\
\end{array}\right. \isdef \hat{\sigma}_{v,N}^2 \delta(l)
$

where

$\displaystyle \hat{\sigma}_{v,N}^2 \isdef \frac{1}{N}\sum_{n=0}^{N-1} \left\vert v(n)\right\vert^2
$

is defined as the sample variance of $ v$.6.4

The plot in the upper left corner of Fig.5.1 shows the sample autocorrelation obtained for 32 samples of pseudorandom numbers (synthetic random numbers). (For reasons to be discussed below, the sample autocorrelation has been multipled by a Bartlett (triangular) window.) Proceeding down the column on the left, the results of averaging many such sample autocorrelations can be seen. It is clear that the average sample autocorrelation function is approaching an impulse function, as desired by definition for white noise. (The right column shows the Fourier transform of each sample autocorrelation function, which is a smoothed estimate of the power spectral density, as discussed in §5.6 below.)

Figure 5.1: Averaged sample autocorrelations and their Fourier transforms.
\includegraphics[width=\textwidth]{eps/twhite}

For stationary stochastic processes $ v(n)$, the sample autocorrelation function $ \hat{r}_{v,N}(l)$ approaches the true autocorrelation function $ r_v(l)$ in the limit as the number of observed samples $ N$ goes to infinity, i.e.,

$\displaystyle \lim_{N\to\infty} \hat{r}_{v,N}(l) = r_v(l).
$

The true autocorrelation function of a random process is defined in Appendix D. For our purposes here, however, the above limit can be taken as the definition of the true autocorrelation function for the noise sequence $ v(n)$.

At lag $ l=0$, the autocorrelation function of a zero-mean random process $ v(n)$ reduces to the variance:

$\displaystyle r_v(0) \isdef \lim_{N\to\infty}\frac{1}{N}\sum_{m=0}^{N-1} \left\vert v(m)\right\vert^2
= \sigma_v^2
$

The variance can also be called the average power or mean square. The square root $ \sigma_v$ of the variance is called the standard deviation or root mean square (RMS).


Order a Hardcopy of Spectral Audio Signal Processing

Previous: Testing for White Noise
Next: Sample Power Spectral Density

written by Julius Orion Smith III
Julius Smith's background is in electrical engineering (BS Rice 1975, PhD Stanford 1983). He is presently Professor of Music and Associate Professor (by courtesy) of Electrical Engineering at Stanford's Center for Computer Research in Music and Acoustics (CCRMA), teaching courses and pursuing research related to signal processing applied to music and audio systems. See http://ccrma.stanford.edu/~jos/ for details.


Comments


No comments yet for this page


Add a Comment
You need to login before you can post a comment (best way to prevent spam). ( Not a member? )