g13ca calculates the smoothed sample spectrum of a univariate time series using one of four lag windows – rectangular, Bartlett, Tukey or Parzen window.
Syntax
C# |
---|
public static void g13ca( int nx, int mtx, double px, int iw, int mw, int ic, int nc, double[] c, int kc, int l, int lg, double[] xg, out int ng, double[] stats, out int ifail ) |
Visual Basic |
---|
Public Shared Sub g13ca ( _ nx As Integer, _ mtx As Integer, _ px As Double, _ iw As Integer, _ mw As Integer, _ ic As Integer, _ nc As Integer, _ c As Double(), _ kc As Integer, _ l As Integer, _ lg As Integer, _ xg As Double(), _ <OutAttribute> ByRef ng As Integer, _ stats As Double(), _ <OutAttribute> ByRef ifail As Integer _ ) |
Visual C++ |
---|
public: static void g13ca( int nx, int mtx, double px, int iw, int mw, int ic, int nc, array<double>^ c, int kc, int l, int lg, array<double>^ xg, [OutAttribute] int% ng, array<double>^ stats, [OutAttribute] int% ifail ) |
F# |
---|
static member g13ca : nx : int * mtx : int * px : float * iw : int * mw : int * ic : int * nc : int * c : float[] * kc : int * l : int * lg : int * xg : float[] * ng : int byref * stats : float[] * ifail : int byref -> unit |
Parameters
- nx
- Type: System..::..Int32On entry: , the length of the time series.Constraint: .
- mtx
- Type: System..::..Int32On entry: if covariances are to be calculated by the method (), mtx must specify whether the data are to be initially mean or trend corrected.
- For no correction.
- For mean correction.
- For trend correction.
Constraint: if ,If covariances are supplied (), mtx is not used.
- px
- Type: System..::..DoubleOn entry: if covariances are to be calculated by the method (), px must specify the proportion of the data (totalled over both ends) to be initially tapered by the split cosine bell taper.Constraint: .
- 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. Windowed covariances at lag or greater are zero.Constraint: .
- ic
- Type: System..::..Int32On entry: indicates whether covariances are to be calculated in the method or supplied in the call to the method.
- Covariances are to be calculated.
- Covariances are to be supplied.
- nc
- Type: System..::..Int32On entry: the number of covariances to be calculated in the method or supplied in the call to the method.Constraint: .
- c
- 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 covariances. l should be a product of small primes such as where is the smallest integer such that , provided .
- lg
- Type: System..::..Int32On entry: indicates whether unlogged or logged spectral estimates and confidence limits are required.
- Unlogged.
- Logged.
- xg
- Type: array<System..::..Double>[]()[][]An array of size [nxg]On entry: if the covariances are to be calculated, then xg must contain the nx data points. If covariances are supplied, xg may contain any values.On exit: contains the ng spectral estimates, , for in to respectively (logged if ). The elements , for contain .
- ng
- Type: System..::..Int32%On exit: the number of spectral estimates, , in xg.
- stats
- Type: array<System..::..Double>[]()[][]An array of size []On exit: four associated statistics. These are the degrees of freedom in , the lower and upper confidence limit factors in and respectively (logged if ), and the bandwidth in .
- 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 spectrum is defined as
where is the window width, and is calculated for frequency values
where denotes the integer part.
The autocovariances may be supplied by you, or constructed from a time series , as
the fast Fourier transform (FFT) being used to carry out the convolution in this formula.
The time series may be mean or trend corrected (by classical least squares), and tapered before calculation of the covariances, the tapering factors being those of the split cosine bell:
where and is the tapering proportion.
The smoothing window is defined by
which for the various windows is defined over by
rectangular:
Bartlett:
Tukey:
Parzen:
The sampling distribution of is approximately that of a scaled variate, whose degrees of freedom is provided by the method, together with multiplying limits , from which approximate confidence intervals for the true spectrum may be constructed as
. Alternatively, log may be returned, with additive limits.
The bandwidth of the corresponding smoothing window in the frequency domain is also provided. Spectrum estimates separated by (angular) frequencies much greater than may be assumed to be independent.
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:
On entry, , or and , or and , or , or , or , or , or , or , or , or , or and , or and .
On entry, , or kc has a prime factor exceeding , or kc has more than prime factors, counting repetitions. This error only occurs when .
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
g13ca carries out two FFTs of length kc to calculate the covariances and one FFT of length l to calculate the sample spectrum. The time taken by the method for an FFT of length is approximately proportional to (but see [Further Comments] in c06pa for further details).
Example
This example reads a time series of length . It selects the mean correction option, a tapering proportion of , the Parzen smoothing window and a cut-off point for the window at lag . It chooses to have auto-covariances calculated and unlogged spectral estimates at a frequency division of . It then calls g13ca to calculate the univariate spectrum and statistics and prints the autocovariances and the spectrum together with its confidence multiplying limits.
Example program (C#): g13cae.cs