corrcorrelation, covarianceSyntax
[cov,Mean] = corr(x,[y],nlags)
[cov,Mean] = corr('fft',xmacro,[ymacro],n,sect)
[w,xu] = corr('updt',x1,[y1],w0)
[w,xu] = corr('updt',x2,[y2],w,xu)
...
wk = corr('updt',xk,[yk],w,xu)
Argumentsxa real vectorya real vector, default value x.nlagsinteger, number of correlation coefficients desired.xmacroa scilab external (see below).ymacroa scilab external (see below), default value xmacronan integer, total size of the sequence (see below).sectsize of sections of the sequence (see below).xia real vectoryia real vector,default value xi.covreal vector, the correlation coefficientsMeanreal number or vector, the mean of x and if given yDescriptioncorr(x,y,…) computes
cov(m)=\sum_{k=1}^{n-m} \left(x(k)-mean(x)\right)\left(y(m+k)-mean(y)\right) / n
for m = 0, …, nlag-1.
Note that if x and y sequences are differents corr(x,y,...) is
different with corr(y,x,...)
Short sequences[cov,Mean]=corr(x,[y],nlags) returns the first nlags
correlation coefficients and Mean = mean(x)
(mean of [x,y] if y is an argument).
The sequence x (resp. y) is assumed real, and x
and y are of same dimension n.
Long sequences[cov,Mean]=corr('fft',xmacro,[ymacro],n,sect).
Here xmacro is either
a function of type [xx]=xmacro(sect,istart) which
returns a vector xx of dimension
nsect containing the part of the sequence with
indices from istart to
istart+sect-1.
a fortran subroutine or C procedure which performs the same
calculation. (See the source code of dgetx for an
example).
n = total size of the sequence.
sect = size of sections of the sequence.
sect must be a power of 2.
cov has dimension sect.
Calculation is performed by FFT.
Updating method
With this syntax the calculation is updated at each
call to corr.
x1,x2,... are parts of x such that
x=[x1,x2,...] and sizes of xi a power of
2. To get nlags coefficients a final fft must be
performed c=fft(w,1)/n; cov=c(1nlags)
(n is the size of x (y)). Caution: this
syntax assumes that xmean = ymean = 0.
ExamplesSee also
xcorr
xcov
correl
cov
covar