# Oracle function for obtaining a particular taper/window

### Description

Develop signal processing tapers or windows.

### Usage

1 2 3 4 |

### Arguments

`bandwidth` |
bandwidth for DPSS tapers.
See |

`beta` |
kaiser window shape factor (must be positive or zero).
See |

`cutoff` |
parzen or Papoulis window cutoff (must be greater than unity).
See |

`flatness` |
raised cosine taper flatness fraction (must be on [0,1]).
See |

`n.sample` |
an integer denoting the number of samples. Default: 1000. |

`n.taper` |
an integer defining the multitaper order (number of orthogonal tapers) to use
in a multitaper scheme. The taper order directly impacts the quality of
the SDF estimate. Low taper orders are usually associated with SDF estimates with low bias and high variance,
while high taper orders attenuate the variance of the estimate at the risk of incurring a large bias.
This tradeoff between bias and variance is unavoidable but taper order allows you to tune the SDF
to meet the needs of your application. Studies show that a multitaper order of 5 typically provides a good balance
with reasonably low bias and variance properties (see the references for more details). Default: |

`normalize` |
a logical value. If |

`roughness` |
daniell windown roughness factor (must be positive).
See |

`sidelobedB` |
chebyshev sidelobedB bandwidth in decibels
(must be positive).
See |

`sigma` |
standard deviation for Guassian taper. Default: 0.3. |

`type` |
a character string denoting the type of taper to create.
Supported types are |

### Details

Let *w()* and *h(t)* for t = 0, ..., N-1
be a *lag window* and *taper*, respectively.
The following lag window or taper types are supported.

- rectangular
A rectangular taper is defined as

*h(t) = 1*.- triangle
A triangular taper is defined as

*h(t)=h(N-t-1)=2*(t+1)/(N+1)*for*t < M*where*M=floor(N/2)*and*h(M) = 1*if*N*is evenly divisible by 2.- raised cosine
A raised cosine is a symmetric taper with a flat mid-plateau. Let

*p on [0,1]*be the fraction of the length of the taper that is flat,*M=floor(p*N)*, and*B=2*pi/(M+1)*. A raised cosine taper is defined as*h(t) = h(N-t-1) = 0.5 * (1 - cos(B*(t+1))) for 0 <= t < floor(M/2) and**h(t) = 1 for floor(M/2) <= t < N - floor(M/2).*- hanning
Let

*B=2*pi/(N+1)*. A Hanning taper is defined as*h(t) = 0.5 * (1 - cos(B*(t+1)))*.- hamming
Let

*B=2*pi/(N-1)*. A Hamming taper is defined as*h(t) = 0.54 - 0.46 * cos(B*t)*.- blackman
Let

*B=2*pi/(N+1)*. A Blackman taper is defined as*h(t) = 0.42 - 0.5 * cos( B * ( t + 1 ) ) + 0.08 * cos( 2 * B * ( t + 1 ) )*.- nuttall
Let

*B=2*pi/(N-1)*. A Nuttall taper is defined as*h(t) = 0.3635819 - 0.4891775 * cos( B*t ) + 0.1365995 * cos( 2*B*t ) - 0.0106411 * cos( 3*B*t )*- gaussian
Let

*S*be the standard deviation of a Gaussian distribution. Let*B(t)=2*S*(0.5 - t/(N-1))*. A Gaussian taper is defined as*h(t) = h(N-t-1) = exp(-B*B/2) for 0 <= t < floor(N/2)*.

*h(N/2)=1 if N is evenly divisible by 2*.

- kaiser
Let

*V(t) = (2t-1-N)/N*and*I0()*be the zeroth-order modified Bessel function of the first kind. Given the shape factor*beta > 0*, a Kaiser taper is defined as*h(t) = I0(beta*sqrt(1-V(t)\eqn{\mbox{\textasciicircum}}{^}2))/I0(beta)*.- chebyshev
The Dolph-Chebyshev taper is a function of both the desired length

*N*and the desired sidelobe level (our routine accepts a sidelobe attenuation factor expressed in decibels). See the Mitra reference for more details.- born jordan
Let

*M=(N-1)/2*. A Born-Jordan taper is defined as*h(t) = h(N-t-1) = 1 / ( M - t + 1 )*.- sine
Sine multitapers are defined as

*h(k,t) = sqrt(2/(N+1)) * sin((k+1)*pi*(t+1)/(N+1))*for t = 0, ..., N-1 and k = 0, ..., .. This simple equation defines a good approximation to the discrete prolate spheroidal sequences (DPSS) used in multitaper SDF estimation schemes.

- parzen
A Parzen lag window is defined as

*w(t,m)= {1 - 6(t/m)^2 + 6(|t|/m)^3} for |t| <= m/2; {2(1 - |t|/m)^3} for m/2 < |t| <= m; and 0 otherwise*for

*-(N-1) <= t <= (N - 1)*. The variable*m*is referred to as the*cutoff*since all values beyond that point are zero.- papoulis
A Papoulis lag window is defined as

*w(t,m)= {(1/pi) * |sin(pi*t/m)| + (1 - |t|/m) * cos(pi*t/m)} for |t| < m; and 0 otherwise*for

*-(N-1) <= t <= (N - 1)*. The variable*m*is referred to as the*cutoff*since all values beyond that point are zero.- daniell
A Daniell lag window is defined as

*w(t,m)= {sin(pi*t/m)/(pi*t/m)} for |t| < N; and 0 for |t| >= N*for

*-(N-1) <= t <= (N - 1)*. The variable*m*is referred to as the*roughness*factor, since, in the context of spectral density function (SDF) estimation, it controls the degree of averaging that is performed on the preliminary direct SDF estimate. The smaller the roughness, the greater the amount of smoothing.- dpss
Discrete prolate spheroidal sequences are (typically) used for multitaper spectral density function estimation. The first order DPSS can be defined (to a good approximation) as

*h(t,k) = C * I0( W' * sqrt(1 - (1 - g(t))^2) / I0(W')*for

*t=1,...,N*, where*C*is a scaling constant used to force the normalization*sum[t=0,...,N-1]{h(t,k)^2}=1*;*W'=pi*W*(N-1)*dt*where*dt*is the sampling interval;*g(t)=(2*t-1)/N*; and*I0()*is the modified Bessel function of the first kind and zeroth order. The parameter*W*is related to the*resolution bandwidth*since it roughly defines the desired half-width of the central lobe of the resulting spectral window. Higher order DPSS tapers (i.e.,*h(t,k)*for*k > 0*) can be calculated using a relatively simple tridiagonalization formulation (see the references for more information). Finally, we note that the sampling interval*dt*can be set to unity without any loss of generality.

### Value

an object of class `taper`

.

### S3 METHODS

- as.matrix
converts output to a matrix.

- plot
plots the output. Optional arguments are:

- ylab
Character string denoting the y-axis label for the plot. Default:

`upperCase(attr(x,"type"))`

.- type
Line type (same as the

`type`

argument of the`par`

function). Default: "l".- ...
Additional plot arguments (set internally by the

`par`

function).

prints a summary of the output object.

### References

A. T. Walden, “Accurate Approximation of a 0th Order Discrete Prolate
Spheroidal Sequence for Filtering and Data Tapering", *Signal Processing*,
**18**, 341–8 (1989).

Percival, Donald B. and Constantine, William L. B. (2005)
“Exact Simulation of Gaussian Time Series
from Nonparametric Spectral Estimates
with Application to Bootstrapping",
*Journal of Computational and Graphical Statistics*,
accepted for publication.

D.B. Percival and A. Walden (1993),
*Spectral Analysis for Physical Applications: Multitaper
and Conventional Univariate Techniques*,
Cambridge University Press, Cambridge, UK.

S.K.Mitra, J. Kaiser (1993),
*Handbook for Digital Signal Processing*, John Wiley and Sons, Inc.

### See Also

`taper`

.

### Examples

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ```
## change plot layout
gap <- 0.11
old.plt <- splitplot(4,4,1,gap=gap)
## create a plot of all supported tapers and
## windows
nms <- c("rectangle", "triangle", "raised cosine",
"hanning", "hamming", "blackman",
"nuttall", "gaussian", "kaiser",
"chebyshev", "born jordan", "sine",
"parzen", "papoulis", "daniell", "dpss")
for (i in seq(along=nms)){
if (i > 1) splitplot(4,4,i,gap=gap)
plot(taper(type=nms[i]))
}
## restore plot layout to initial state
par(old.plt)
``` |