Scilab Function

corr - correlation, covariance

Calling Sequence





                n - m 
                 \                                                 1
        cov(m) =  >        (x(k)  - xmean) (y(m+k)      - ymean) * ---
                 /                                                  n
                 k = 1

for m=0,..,nlag-1 and two vectors x=[x(1),..,x(n)] y=[y(1),..,y(n)]

Note that if x and y sequences are differents corr(x,y,...) is different with corr(y,x,...)

Short sequences:

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:

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 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 calling sequence the calculation is updated at each call to corr.

    w0 = 0*ones(1,2*nlags);
    nlags = power of 2.

    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 calling sequence assumes that xmean = ymean = 0.


    See Also