Skip to contents

Computes a Tukey (tapered cosine) window of length n with taper parameter alpha. The Tukey window is rectangular when alpha = 0 and becomes a Hann window when alpha = 1.

Usage

tukey_window(n, alpha)

Arguments

n

Integer. Length of the window (number of points).

alpha

Numeric in [0, 1]. Shape parameter controlling the fraction of the window inside the cosine tapered regions.

  • alpha = 0: rectangular window.

  • 0 < alpha < 1: Tukey window with cosine tapers.

  • alpha = 1: Hann window.

Value

A numeric vector of length n containing the Tukey window values.

Details

The Tukey window is defined piecewise: $$ w[m] = \begin{cases} \tfrac{1}{2}\left[1+\cos\!\left(\pi\left(\tfrac{2m}{\alpha(N-1)}-1\right)\right)\right], & 0 \leq m < \tfrac{\alpha(N-1)}{2}, \\ 1, & \tfrac{\alpha(N-1)}{2} \leq m \leq (N-1)(1-\tfrac{\alpha}{2}), \\ \tfrac{1}{2}\left[1+\cos\!\left(\pi\left(\tfrac{2m}{\alpha(N-1)}-\tfrac{2}{\alpha}+1\right)\right)\right], & (N-1)(1-\tfrac{\alpha}{2}) < m \leq N-1. \end{cases} $$

where \(N\) is the window length. For alpha = 0 the definition reduces to a rectangular window, and for alpha = 1 to a Hann window.

Examples

if (FALSE) { # \dontrun{
# Rectangular window
tukey_window(8, alpha = 0)

# Hann window
tukey_window(8, alpha = 1)

# General Tukey window
tukey_window(16, alpha = 0.5)
} # }