Tukey window function: tukey_window

### 15.2.26 Tukey window function: tukey_window

The tukey_window command finds a Tukey window of a sequence.

- tukey_window takes one mandatory argument and two optional arguments:
  - v, a real vector with length n.
  - Optionally, α, a real number in [0,1] (by default 0.5).
  - Optionally, an interval n0..n1 (by default 0..(n−1)).
- tukey_window(v ⟨,α,n1..n2⟩) returns the elementwise product of [vn1,…,vn2] and the vector w of length N=n2−n1+1 defined by

  wk= |
  ⎧ ⎪ ⎪ ⎪ ⎪ ⎪ ⎨ ⎪ ⎪ ⎪ ⎪ ⎪ ⎩ |
  1
  2
  |  | ⎛ ⎜ ⎜ ⎝ | 1+cos | ⎛ ⎜ ⎜ ⎝ | π | ⎛ ⎜ ⎜ ⎝ |
  k
  β
  | −1 | ⎞ ⎟ ⎟ ⎠ | ⎞ ⎟ ⎟ ⎠ | ⎞ ⎟ ⎟ ⎠ | ,
  | k<β,
  1, |
  β≤ k≤(N−1) | ⎛ ⎜ ⎜ ⎝ | 1− |
  α
  2
  | ⎞ ⎟ ⎟ ⎠ | ,
  1
  2
  |  | ⎛ ⎜ ⎜ ⎝ | 1+cos | ⎛ ⎜ ⎜ ⎝ | π | ⎛ ⎜ ⎜ ⎝ |
  k
  β
  | − |
  2
  α
  | +1 | ⎞ ⎟ ⎟ ⎠ | ⎞ ⎟ ⎟ ⎠ | ⎞ ⎟ ⎟ ⎠ | ,
  | otherwise,

  where β=α (N−1)/2, for k=0,1,…,N−1.

Example.
Input:

L0:=randvector(1000,0..1):;
scatterplot(L0);

Output:

Input:

L:=tukey_window(L0,0.4):;
scatterplot(L);

Output: