The triangular window coefficients are given by the following formula
where N is the length of the filter and k = 0, 1, …, N – 1.
Different definitions may use N / 2 or (N + 1) / 2 in the denominator of the last expression. When (N – 1) /2 is used, as in the formula above, the window is also known as the Bartlett window, or the triangular window with zero end points.
Consider a finite impulse response (FIR) low pass filter of length N = 201. The following is the triangular window.
Given a sampling frequency of 2000 Hz and a filter cutoff frequency of 40 Hz, the impulse response of the filter with a rectangular window (with no window) and with the triangular window is as follows.
The magnitude response of the same filter is shown on the graph below.
Deriving the triangular window from the rectangular window
Take two rectangular windows f(k) and g(n) of length N.
The convolution of f(k) and g(n) is as follows.
The second sum above follows as f(k) is zero outside of the interval from 0 to N – 1 and 1 inside that interval.
If n < 0, the convolution is zero. If 0 ≤ n ≤ N – 1, then the sum above evaluates to n. By the fact that g = 1 only for 0 ≤ n – m ≤ N – 1, which is equivalent to n – (N – 1) ≤ m ≤ n, when n > N – 1
Thus, the convolution of two rectangular windows of length N produces
This is a triangular window, which, however, is of twice the length of the rectangular windows (less 1). Replacing N – 1 with (N – 1) / 2 and scaling the window to peak at 1 produces the triangular window formula at the beginning of this topic.
Windows that are produced by the convolution of the rectangular window are known as basic spline or B-spline windows. They include the rectangular window (order 1), the triangular window (order 2), and the Parzen window (order 4), where each successive order is produced by convolving the previous order with the same rectangular window.
Measures for the triangular window
The following graph compares the discrete Fourier transform of the triangular window with that of the rectangular window.
The triangular window measures are as follows.