winweights: Discrete windows

Description Usage Arguments Examples

Description

Generate coefficients for various popular window functions

Usage

1
2
winweights(width = 11, type = "epanechnikov", a = 3, step.adj = TRUE,
  lev.adj = "sum")

Arguments

width

integer; width of the window

type

charachter; name of the window function

one of:
• square, rectangle, boxcar: Regular flat window
• triangle, triangular: Isosceles (symmetric) triangular window
• epanechnikov, welch, parabolic: Negative parabola
• quartic, biweight: ...
• triweight: ...
• tricube: ...
• cosine-smooth, cosine: ...
• optcosine, sine: ...
• hann: ...
• hamming: ...
• blackman: ...
• nuttall: ...
• blackman-nuttall: ...
• blackman-harris: ...
• flat-top: ...
• blackman-harris: ...
• kaiser-bessel, kaiser: ...
• lanczos: ...
• sinc: ...
• poisson: ...
• hann-poisson: ...
step.adj

logical; should the end points be a small step above zero?

lev.adj

character; how the levels should be scaled

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Time and frequency plots for each window 
name <- c("square", "triangle", "epanechnikov", "biweight", "triweight",
          "tricube", "cosine-smooth", "optcosine",
          "hann", "hamming", "blackman", "nuttall", "blackman-nuttall",
          "blackman-harris", "flat-top", "kaiser-bessel",
          "lanczos", "sinc", "poisson", "hann-poisson")

w <- 99
par(mfcol=c(5, 4), mar=c(1.5, 1.5, 0.5, 0.5), mgp=c(0, 0.6, 0), oma=c(0.1, 0.1, 0.1, 0.1))
for (i in name) {
    plot(winweights(w, type=i, a=3), type="l", xlab="", ylab="", ylim=c(-0.02, 0.06))
    grid(col="#00000022", lty=1)
    legend("topright", legend=i, bty="n", text.col="blue", adj=c(0.2, 0))
}

set.seed(1)
w <- 99
x <- rnorm(5e4)
i <- 1
par(mfcol=c(5, 4), mar=c(1.5, 1.5, 0.5, 0.5), mgp=c(0, 0.6, 0), oma=c(0.1, 0.1, 0.1, 0.1))
for (i in 1:length(name)) {
    win <- winweights(w, type=name[i], step.adj=FALSE, lev.adj="sum", a=3)
    rol <- rollconv(x, win, partial=FALSE, scale.window=FALSE)
    spectrum(na.omit(rol), main="", xlab="", ylab="", sub="", lwd=0.1, ylim=c(1e-16, 1))
    grid(col="#00000022", lty=1)
    legend("topright", legend=name[i], bty="n", text.col="blue", adj=c(0.2, 0))
}

AkselA/R-rollfun documentation built on May 31, 2019, 8:41 a.m.