g13cb calculates the smoothed sample spectrum of a univariate time series using spectral smoothing by the trapezium frequency (Daniell) window.
Syntax
C# |
---|
public static void g13cb( int nx, int mtx, double px, int mw, double pw, int l, int kc, int lg, double[] xg, out int ng, double[] stats, out int ifail ) |
Visual Basic |
---|
Public Shared Sub g13cb ( _ nx As Integer, _ mtx As Integer, _ px As Double, _ mw As Integer, _ pw As Double, _ l As Integer, _ kc 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 g13cb( int nx, int mtx, double px, int mw, double pw, int l, int kc, int lg, array<double>^ xg, [OutAttribute] int% ng, array<double>^ stats, [OutAttribute] int% ifail ) |
F# |
---|
static member g13cb : nx : int * mtx : int * px : float * mw : int * pw : float * l : int * kc : 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: whether the data are to be initially mean or trend corrected.
- For no correction.
- For mean correction.
- For trend correction.
Constraint: .
- px
- Type: System..::..DoubleOn entry: 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.)Constraint: .
- mw
- Type: System..::..Int32On entry: the value of which determines the frequency width of the smoothing window as . A value of implies no smoothing is to be carried out.Constraint: .
- pw
- Type: System..::..DoubleOn entry: , the shape parameter of the trapezium frequency window.A value of gives a triangular window, and a value of a rectangular window.If (i.e., no smoothing is carried out), pw is not used.Constraint: .
- l
- Type: System..::..Int32On entry: , the frequency division of smoothed spectral estimates as .
- kc
- Type: System..::..Int32On entry: , the order of the fast Fourier transform (FFT) used to calculate the spectral estimates. kc should be a multiple 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.
- For unlogged.
- For logged.
- xg
- Type: array<System..::..Double>[]()[][]An array of size [kc]On entry: the data points.On exit: contains the ng spectral estimates , for , in to (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 supplied time series may be mean or trend corrected (by least squares), and tapered, the tapering factors being those of the split cosine bell:
where and is the tapering proportion.
The unsmoothed sample spectrum
is then calculated for frequency values
where [ ] denotes the integer part.
The smoothed spectrum is returned as a subset of these frequencies for which is a multiple of a chosen value , i.e.,
where . You will normally fix first, then choose so that is sufficiently large to provide an adequate representation for the unsmoothed spectrum, i.e., . It is possible to take , i.e., .
The smoothing is defined by a trapezium window whose shape is supplied by the function
the proportion being supplied by you.
The width of the window is fixed as by you supplying . A set of averaging weights are constructed:
where is a normalizing constant, and the smoothed spectrum obtained is
If no smoothing is required should be set to , in which case the values returned are . Otherwise, in order that the smoothing approximates well to an integration, it is essential that , and preferable, but not essential, that be a multiple of . A choice of would normally be required to supply an adequate description of the smoothed spectrum. Typical choices of and should be adequate for usual smoothing situations when .
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 95% 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
Note: g13cb may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the method:
On entry, , or , or , or , or , or , or , or and , or and , or .
On entry, , or kc is not a multiple of l, or kc has a prime factor exceeding , or kc has more than prime factors, counting repetitions.
- This indicates that a serious error has occurred. Check all array subscripts and method parameter lists in calls to g13cb. Seek expert help.
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
g13cb carries out a FFT of length kc to calculate the sample spectrum. The time taken by the method for this is approximately proportional to (but see [Further Comments] in c06pa for further details).
Example
This example reads a time series of length . It then calls g13cb to calculate the univariate spectrum and prints the logged spectrum together with confidence limits.
Example program (C#): g13cbe.cs