g13cc calculates the smoothed sample cross spectrum of a bivariate time series using one of four lag windows: rectangular, Bartlett, Tukey or Parzen.
Syntax
C# |
---|
public static void g13cc( int nxy, int mtxy, double pxy, int iw, int mw, int ish, int ic, int nc, double[] cxy, double[] cyx, int kc, int l, double[] xg, double[] yg, out int ng, out int ifail ) |
Visual Basic |
---|
Public Shared Sub g13cc ( _ nxy As Integer, _ mtxy As Integer, _ pxy As Double, _ iw As Integer, _ mw As Integer, _ ish As Integer, _ ic As Integer, _ nc As Integer, _ cxy As Double(), _ cyx As Double(), _ kc As Integer, _ l As Integer, _ xg As Double(), _ yg As Double(), _ <OutAttribute> ByRef ng As Integer, _ <OutAttribute> ByRef ifail As Integer _ ) |
Visual C++ |
---|
public: static void g13cc( int nxy, int mtxy, double pxy, int iw, int mw, int ish, int ic, int nc, array<double>^ cxy, array<double>^ cyx, int kc, int l, array<double>^ xg, array<double>^ yg, [OutAttribute] int% ng, [OutAttribute] int% ifail ) |
F# |
---|
static member g13cc : nxy : int * mtxy : int * pxy : float * iw : int * mw : int * ish : int * ic : int * nc : int * cxy : float[] * cyx : float[] * kc : int * l : int * xg : float[] * yg : float[] * ng : int byref * ifail : int byref -> unit |
Parameters
- nxy
- Type: System..::..Int32On entry: , the length of the time series and .Constraint: .
- mtxy
- Type: System..::..Int32On entry: if cross-covariances are to be calculated by the method (), mtxy must specify whether the data is to be initially mean or trend corrected.
- For no correction.
- For mean correction.
- For trend correction.
If cross-covariances are supplied , mtxy is not used.Constraint: if , , or .
- pxy
- Type: System..::..DoubleOn entry: if cross-covariances are to be calculated by the method (), pxy must specify the proportion of the data (totalled over both ends) to be initially tapered by the split cosine bell taper. A value of implies no tapering.If cross-covariances are supplied , pxy is not used.Constraint: if , .
- iw
- Type: System..::..Int32On entry: the choice of lag window.
- Rectangular.
- Bartlett.
- Tukey.
- Parzen.
Constraint: .
- mw
- Type: System..::..Int32On entry: , the ‘cut-off’ point of the lag window, relative to any alignment shift that has been applied. Windowed cross-covariances at lags or less, and at lags or greater are zero.Constraints:
- ;
- .
- ish
- Type: System..::..Int32On entry: , the alignment shift between the and series. If leads , the shift is positive.Constraint: .
- ic
- Type: System..::..Int32On entry: indicates whether cross-covariances are to be calculated in the method or supplied in the call to the method.
- Cross-covariances are to be calculated.
- Cross-covariances are to be supplied.
- nc
- Type: System..::..Int32On entry: the number of cross-covariances to be calculated in the method or supplied in the call to the method.Constraint: .
- cxy
- Type: array<System..::..Double>[]()[][]An array of size [nc]
- cyx
- Type: array<System..::..Double>[]()[][]An array of size [nc]
- kc
- Type: System..::..Int32
- l
- Type: System..::..Int32On entry: , the frequency division of the spectral estimates as . Therefore it is also the order of the FFT used to construct the sample spectrum from the cross-covariances. l should be a product of small primes such as where is the smallest integer such that .
- xg
- Type: array<System..::..Double>[]()[][]An array of size [dim1]Note: dim1 must satisfy the constraint:
- if , ;
- otherwise .
On entry: if the cross-covariances are to be calculated, then xg must contain the nxy data points of the series. If covariances are supplied, xg need not be set.On exit: contains the real parts of the ng complex spectral estimates in elements to , and to contain . The series leads the series.
- yg
- Type: array<System..::..Double>[]()[][]An array of size [dim1]Note: dim1 must satisfy the constraint:
- if , ;
- otherwise .
On entry: if cross-covariances are to be calculated, yg must contain the nxy data points of the series. If covariances are supplied, yg need not be set.On exit: contains the imaginary parts of the ng complex spectral estimates in elements to , and to contain . The series leads the series.
- ng
- Type: System..::..Int32%
- ifail
- Type: System..::..Int32%On exit: unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).
Description
The smoothed sample cross spectrum is a complex valued function of frequency , , defined by its real part or co-spectrum
and imaginary part or quadrature spectrum
where , for , is the smoothing lag window as defined in the description of g13ca. The alignment shift is recommended to be chosen as the lag at which the cross-covariances peak, so as to minimize bias.
The results are calculated for frequency values
where denotes the integer part.
The cross-covariances may be supplied by you, or constructed from supplied series ; as
this convolution being carried out using the finite Fourier transform.
The supplied series may be mean and trend corrected and tapered before calculation of the cross-covariances, in exactly the manner described in g13ca for univariate spectrum estimation. The results are corrected for any bias due to tapering.
The bandwidth associated with the estimates is not returned. It will normally already have been calculated in previous calls of g13ca for estimating the univariate spectra of and .
References
Bloomfield P (1976) Fourier Analysis of Time Series: An Introduction Wiley
Jenkins G M and Watts D G (1968) Spectral Analysis and its Applications Holden–Day
Error Indicators and Warnings
Errors or warnings detected by the method:
Some error messages may refer to parameters that are dropped from this interface
(NXYG) In these
cases, an error in another parameter has usually caused an incorrect value to be inferred.
On entry, , or and , or and , or and , or and , or , or , or , or , or , or , or ,
Accuracy
The FFT is a numerically stable process, and any errors introduced during the computation will normally be insignificant compared with uncertainty in the data.
Parallelism and Performance
None.
Further Comments
g13cc carries out two FFTs of length kc to calculate the sample cross-covariances and one FFT of length to calculate the sample spectrum. The timing of g13cc is therefore dependent on the choice of these values. The time taken for an FFT of length is approximately proportional to (but see [Further Comments] in c06pa for further details).
Example
This example reads two time series of length . It then selects mean correction, a 10% tapering proportion, the Parzen smoothing window and a cut-off point of for the lag window. The alignment shift is set to and cross-covariances are chosen to be calculated. The program then calls g13cc to calculate the cross spectrum and then prints the cross-covariances and cross spectrum.
Example program (C#): g13cce.cs