Functions for computing autocovariances, autocorrelations, crosscovariances, and crosscorrelations for an input vector with missing data. The normalizing factor in the denominator (xvar) is kept constant.
function esacr( x : float, mxlag[1] : integer ) function esacv( x : float, mxlag[1] : integer ) function esccr( x : float, y : float, mxlag[1] : integer ) function esccv( x : float, y : float, mxlag[1] : integer )
Given vectors/arrays (x, y), esccv and esccr compute sample crosscovariances and crosscorrelations respectively, returning a multi-dimensional array of the same dimensions as x and y except with the last dimension npts replaced by mxlag+1.
In the crosscovariance and crosscorrelation computations the y data "lead" the x data.
It is recommended that mxlag not be greater than npts/3, for statistical reasons.
Currently, to calculate positive and negative lags one must invoke this function twice. (See example 5 below.)
acr = esacr(x,10) acv = esacv(x,10)will calculate the autocorrelations and variances at 11 lags (0->10). acr and acv will be one-dimensional variables of length 11.
mxlag = 10 acr_y = esacr(y,mxlag) acv_z = esacv(z(lat|:,lon|:,time|:),mxlag) ; dimension reorderingwill calculate the autocorrelations and variances at (mxlag+1) lags (0->mxlag). acr_y and acv_z will have dimension sizes (nlat,mlon,mxlag+1). (NCL's dimension reordering was used in the latter case.)
ccr = esacr(x,y,10) ccv = esacv(x,y,10)will calculate the cross-correlations and variances at 11 lags (0->10). ccr and ccv will be one-dimensional variables of length 11. The y series leads the x series in the computations.
mxlag = 10 ccr_yz = esccr(y,z,mxlag) ccv_zy = esacv(z,y,mxlag)will calculate the autocorrelations and variances at (mxlag+1) lags (0->mxlag). ccr_yz and ccv_zy will have dimension sizes (nlat,mlon,mxlag+1). Of course, users might have to use dimension reordering if the dimensions are not in the desired order.
mxlag = 9 y_Lead_x = esccr(x,y,mxlag) x_Lead_y = esccr(y,x,mxlag) ; switch the order of the series ccr = new ( 2*mxlag+1, float) ccr(0:mxlag-1) = x_Lead_y(1:mxlag:-1) ; "negative lag", -1 reverses order ccr(mxlag:) = y_Lead_x(0:mxlag) ; "positive lag"Remember that NCL is C based and does not allow negative subscripts like Fortran does (in Fortran, ccr(-mxlag:mxlag)). Thus in the above example ccr(0:mxlag-1) corresponds to lags -9,-8,...,-2,-1 and ccr(mxlag:2*mxlag) corresponds to lags 0,1,2,...,8,9.
In a future release, a single interface which does the above process will be provided.
NG4.1 Home, Index, Examples, Glossary, Feedback, Ref Contents, Ref WhereAmI?