naginterfaces.library.tsa.uni_spectrum_daniell¶
- naginterfaces.library.tsa.uni_spectrum_daniell(nx, mtx, px, mw, pw, l, lg, xg)[source]¶
uni_spectrum_daniell
calculates the smoothed sample spectrum of a univariate time series using spectral smoothing by the trapezium frequency (Daniell) window.For full information please refer to the NAG Library document for g13cb
https://support.nag.com/numeric/nl/nagdoc_30.1/flhtml/g13/g13cbf.html
- Parameters
- nxint
, the length of the time series.
- mtxint
Whether the data are to be initially mean or trend corrected.
For no correction.
For mean correction.
For trend correction.
- pxfloat
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.)
- mwint
The value of which determines the frequency width of the smoothing window as . A value of implies no smoothing is to be carried out.
- pwfloat
, 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), is not used.
- lint
, the frequency division of smoothed spectral estimates as .
- lgint
Indicates whether unlogged or logged spectral estimates and confidence limits are required.
For unlogged.
For logged.
- xgfloat, array-like, shape
The data points.
- Returns
- xgfloat, ndarray, shape
Contains the spectral estimates , for , in to (logged if ). The elements , for , contain .
- ngint
The number of spectral estimates, , in .
- statsfloat, ndarray, shape
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 .
- Raises
- NagValueError
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, , and .
Constraint: if , .
- (errno )
On entry, , and .
Constraint: if , .
- (errno )
On entry, and .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, and .
Constraint: must be a multiple of .
- (errno )
On entry, and .
Constraint: .
- Warns
- NagAlgorithmicWarning
- (errno )
One or more spectral estimates are negative.
Unlogged spectral estimates are returned in , and the degrees of freedom, unloged confidence limit factors and bandwidth in .
- (errno )
The calculation of confidence limit factors has failed.
Spectral estimates (logged if requested) are returned in , and degrees of freedom and bandwidth in .
- Notes
In the NAG Library the traditional C interface for this routine uses a different algorithmic base. Please contact NAG if you have any questions about compatibility.
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 function, 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