Free Books

The Rectangular Window

The (zero-centered) rectangular window may be defined by

$\displaystyle w_R(n) \isdef \left\{ \begin{array}{ll} 1, & -\frac{M-1}{2} \leq n \leq \frac{M-1}{2} \\ 0, & \mbox{otherwise} \\ \end{array} \right.$ (4.2)

where $ M$ is the window length in samples (assumed odd for now). A plot of the rectangular window appears in Fig.3.1 for length $ M=21$ . It is sometimes convenient to define windows so that their dc gain is 1, in which case we would multiply the definition above by $ 1/M$ .

Figure 3.1: The rectangular window.

To see what happens in the frequency domain, we need to look at the DTFT of the window:

W_R(\omega )
& = & \hbox{\sc DTFT}_\omega(w_R) \isdef \sum_{n=-\infty}^\infty
w_R(n)e^{-j\omega n}, \quad \omega\in[-\pi,\pi) \\
& = & \sum_{n=-\frac{M-1}{2}}^{\frac{M-1}{2}} e^{-j \omega n}
= \frac{e^{j \omega \frac{M-1}{2}} - e^{-j \omega \frac{M+1}{2}} }{1 - e^{-j \omega }}

where the last line was derived using the closed form of a geometric series:

$\displaystyle \sum_{n=L}^U r^n = \frac{ r^L - r^{U+1}}{1-r}$ (4.3)

We can factor out linear phase terms from the numerator and denominator of the above expression to get
$\displaystyle W_R(\omega)$ $\displaystyle =$ $\displaystyle \frac{e^{-j \omega \frac{1}{2}}}{e^{-j\omega \frac{1}{2}}}
\left[ \frac{ e^{j \omega \frac{M}{2}}-e^{-j\omega\frac{M}{2}}}
{e^{j \omega\frac{1}{2}}-e^{-j\omega\frac{1}{2}}} \right]$  
  $\displaystyle =$ $\displaystyle \frac{\sin\left(M\frac{\omega}{2}\right)}{\sin\left(\frac{\omega}{2}\right)}
\isdef M\cdot \hbox{asinc}_M(\omega)
\protect$ (4.4)

where $ \hbox{asinc}_M(\omega)$ denotes the aliased sinc function:4.1

$\displaystyle \hbox{asinc}_M(\omega) \isdef \frac{\sin(M\omega/2)}{M\cdot \sin(\omega/2)} \protect$ (4.5)

(also called the Dirichlet function [175,72] or periodic sinc function). This (real) result is for the zero-centered rectangular window. For the causal case, a linear phase term appears:

$\displaystyle W^c_R(\omega) = e^{-j\frac{M-1}{2}\omega} \cdot M \cdot \hbox{asinc}_M(\omega)$ (4.6)

The term ``aliased sinc function'' refers to the fact that it may be simply obtained by sampling the length-$ \tau$ continuous-time rectangular window, which has Fourier transform sinc$ (f \tau)\isdeftext \sin(\pi f \tau)/(\pi f\tau)$ (given amplitude $ 1/\tau$ in the time domain). Sampling at intervals of $ T$ seconds in the time domain corresponds to aliasing in the frequency domain over the interval $ [0,1/T]$ Hz, and by direct derivation, we have found the result. It is interesting to consider what happens as the window duration increases continuously in the time domain: the magnitude spectrum can only change in discrete jumps as new samples are included, even though it is continuously parametrized in $ \tau$ .

As the sampling rate goes to infinity, the aliased sinc function therefore approaches the sinc function

sinc$\displaystyle (x) \isdef \frac{\sin(\pi x)}{\pi x}. \protect$ (4.7)


$\displaystyle \lim_{\stackrel{T\to 0}{MT=\tau}} \hbox{asinc}_M(\omega T) =$   sinc$\displaystyle (\tau f). \protect$ (4.8)

where $ \omega =
2\pi f$ .4.2

Figure 3.2: Fourier transform of the rectangular window.
\includegraphics[width=\textwidth ,height=2.25in]{eps/rectWindowRawFT}

Figure 3.2 illustrates $ W_R(\omega) =
M\cdot\hbox{asinc}_M(\omega)$ for $ M=11$ . Note that this is the complete window transform, not just its real part. We obtain real window transforms like this only for zero-centered, symmetric windows. Note that the phase of rectangular-window transform $ W_R(\omega)$ is zero for $ \vert\omega\vert<2\pi/M$ , which is the width of the main lobe. This is why zero-centered windows are often called zero-phase windows; while the phase actually alternates between 0 and $ \pi$ radians, the $ \pi$ values occur only within side-lobes which are routinely neglected (in fact, the window is normally designed to ensure that all side-lobes can be neglected).

More generally, we may plot both the magnitude and phase of the window versus frequency, as shown in Figures 3.4 and 3.5 below. In audio work, we more typically plot the window transform magnitude on a decibel (dB) scale, as shown in Fig.3.3 below. It is common to normalize the peak of the dB magnitude to 0 dB, as we have done here.

Figure 3.3: Magnitude (dB) of the rectangular-window transform.

Figure 3.4: Magnitude of the rectangular-window Fourier transform.
% latex2html id marker 73365

Figure 3.5: Phase of the rectangular-window Fourier transform.
% latex2html id marker 73369

Rectangular Window Side-Lobes

From Fig.3.3 and Eq.$ \,$ (3.4), we see that the main-lobe width is $ 2\cdot 2\pi/M=4\pi/11 \approx 1.1$ radian, and the side-lobe level is 13 dB down.

Since the DTFT of the rectangular window approximates the sinc function (see (3.4)), which has an amplitude envelope proportional to $ 1/\omega$ (see (3.7)), it should ``roll off'' at approximately 6 dB per octave (since $ -20\log_{10}(2)=6.0205999\ldots$ ). This is verified in the log-log plot of Fig.3.6.

Figure 3.6: Roll-off of the rectangular-window Fourier transform.
\includegraphics[width=\textwidth ]{eps/rectWindowLLFT}

As the sampling rate approaches infinity, the rectangular window transform ( $ \hbox{asinc}$ ) converges exactly to the sinc function. Therefore, the departure of the roll-off from that of the sinc function can be ascribed to aliasing in the frequency domain, due to sampling in the time domain (hence the name `` $ \hbox{asinc}$ '').

Note that each side lobe has width $ \Omega_M \isdeftext 2\pi/M$ , as measured between zero crossings.4.3 The main lobe, on the other hand, is width $ 2\Omega_M$ . Thus, in principle, we should never confuse side-lobe peaks with main-lobe peaks, because a peak must be at least $ 2\Omega_M$ wide in order to be considered ``real''. However, in complicated real-world scenarios, side-lobes can still cause estimation errors (``bias''). Furthermore, two sinusoids at closely spaced frequencies and opposite phase can partially cancel each other's main lobes, making them appear to be narrower than $ 2\Omega_M$ .

In summary, the DTFT of the $ M$ -sample rectangular window is proportional to the `aliased sinc function':

\hbox{asinc}_M(\omega) &\isdef & \frac{\sin(\omega M / 2)}{M\cdot\sin(\omega/2)} \\ [0.2in]
&\approx& \frac{\sin(\pi fM)}{M\pi f} \isdefs \mbox{sinc}(fM)

Thus, it has zero crossings at integer multiples of

$\displaystyle \Omega_M \isdefs \frac{2\pi}{M}.$ (4.11)

Its main-lobe width is $ 2\Omega_M$ and its first side-lobe is 13 dB down from the main-lobe peak. As $ M$ gets bigger, the main-lobe narrows, giving better frequency resolution (as discussed in the next section). Note that the window-length $ M$ has no effect on side-lobe level (ignoring aliasing). The side-lobe height is instead a result of the abruptness of the window's transition from 1 to 0 in the time domain. This is the same thing as the so-called Gibbs phenomenon seen in truncated Fourier series expansions of periodic waveforms. The abruptness of the window discontinuity in the time domain is also what determines the side-lobe roll-off rate (approximately 6 dB per octave). The relation of roll-off rate to the smoothness of the window at its endpoints is discussed in §B.18.

Rectangular Window Summary

The rectangular window was discussed in Chapter 53.1). Here we summarize the results of that discussion.

Definition ($ M$ odd):

$\displaystyle w_R(n) \isdef \left\{\begin{array}{ll} 1, & \left\vert n\right\vert\leq\frac{M-1}{2} \\ [5pt] 0, & \hbox{otherwise} \\ \end{array} \right.$ (4.12)


$\displaystyle W_R(\omega) = M\cdot \hbox{asinc}_M(\omega) \isdef \frac{\sin\left(M\frac{\omega}{2}\right)}{\sin\left(\frac{\omega}{2}\right)}$ (4.13)

The DTFT of a rectangular window is shown in Fig.3.7.

Figure 3.7: Rectangular window discrete-time Fourier transform.


  • Zero crossings at integer multiples of

    $\displaystyle \Omega_M \isdef \frac{2\pi}{M} = \hbox{frequency sampling interval for a length $M$\ DFT.}$ (4.14)

  • Main lobe width is $ 2 \Omega_M = \frac{4\pi}{M} $ .
  • As $ M$ increases, the main lobe narrows (better frequency resolution).
  • $ M$ has no effect on the height of the side lobes (same as the ``Gibbs phenomenon'' for truncated Fourier series expansions).
  • First side lobe only 13 dB down from the main-lobe peak.
  • Side lobes roll off at approximately 6dB per octave.
  • A phase term arises when we shift the window to make it causal, while the window transform is real in the zero-phase case (i.e., centered about time 0).

Next Section:
Generalized Hamming Window Family
Previous Section:
Spectral Interpolation