| Signal Processing Toolbox | Search  Help Desk |
| xcov | Examples See Also |
Cross-covariance function estimate (equal to mean-removed cross-correlation).
Syntax
v = xcov(x,y)
v = xcov(x)
v = xcov(x,'option')
[c,lags] = xcov(x,y,maxlags)
[c,lags] = xcov(x,maxlags)
[c,lags] = xcov(x,y,maxlags,'option')
Description
xcov estimates the cross-covariance sequence of random processes. Autocovariance is handled as a special case.
The true cross-covariance sequence is the mean-removed cross-correlation sequence
xcov estimates the sequence because, in practice, access is available to only a finite segment of the infinite-length random process.
v = xcov(x,y)
returns the cross-covariance sequence in a length 2N-1 vector, where x and y are length N vectors.
v = xcov(x)
is the autocovariance sequence for the vector x. Where x is an N-by-P array, v = xcov(X) returns am array with 2N-1 rows whose P2 columns contain the cross-covariance sequences for all combinations of the columns of X.
By default, xcov computes raw covariances with no normalization. For a length N vector:
c has elements given by c(m) = cxy(m-N), m=1,...,2N-1.
The covariance function requires normalization to estimate the function properly.
v = xcov(x,'option')
specifies a scaling option, where option is:
biased, for biased estimates of the cross-covariance function
unbiased, for unbiased estimates of the cross-covariance function
coeff, to normalize the sequence so the auto-covariances at zero lag are identically 1.0
none, to use the raw, unscaled cross-covariances (default)
[c,lags] = xcov(x,y,maxlags)
where x and y are length m vectors, returns the cross-covariance sequence in a length 2*maxlags+1 vector c. lags is a vector of the lag indices where c was estimated, that is, [-maxlags:maxlags].
[c,lags] = xcov(x,maxlags)
is the autocovariance sequence over the range of lags [-maxlags:maxlags].
[c,lags] = xcov(x,maxlags)
where x is an m-by-p array, returns array c with 2*maxlags+1 rows whose P2 columns contain the cross-covariance sequences for all combinations of the columns of x.
[c,lags] = xcov(x,y,maxlags,'option')
specifies a scaling option, where option is the last input argument.
In all cases, xcov gives an output such that the zeroth lag of the covariance vector is in the middle of the sequence, at element or row maxlag+1 or at m.
Examples
The second outputlags is useful when plotting. For example, the estimated autocovariance of uniform white noise cww(m) can be displayed for -10
m
10 using
ww = randn(1000,1); % generate uniform noise with mean = 1/2 [cov_ww,lags] = xcov(ww,10,'coeff'); stem(lags,cov_ww)
Algorithm
xcov computes the mean of its inputs, subtracts the mean, and then calls xcorr. For more information on estimating covariance and correlation functions, see [1] and [2].
Diagnostics
xcov does not check for any errors other than the correct number of input arguments. Instead, it relies on the error checking in xcorr, which it calls.
See Also
conv |
Convolution and polynomial multiplication. |
corrcoef |
Correlation coefficient matrix. |
cov |
Covariance matrix. |
xcorr |
Cross-correlation function estimate. |
xcorr2 |
Two-dimensional cross-correlation. |
References
[1] Bendat, J.S., and A.G. Piersol. Random Data: Analysis and Measurement Procedures. New York: John Wiley & Sons, 1971. Pg. 332. [2] Oppenheim, A.V., and R.W. Schafer. Digital Signal Processing. Englewood Cliffs, NJ: Prentice Hall, 1975. Pgs. 63-67, 746-747, 839-842.