import matplotlib
if not hasattr(matplotlib.RcParams, "_get"):
matplotlib.RcParams._get = dict.get
7.0 Sampling and the frequency domain#
Let us briefly revisit sampling from Chapter 1, setting quantization aside for now. To sample a continuous signal \(x(t)\), we record its value at evenly spaced instants, at a sampling rate of \(f_s\) \(\frac{\text{samples}}{\text{second}}\). The result is a sequence of samples
so that recording \(T\) seconds of audio produces a vector \(\mathbf{x} \in \mathbb{R}^{T \cdot f_s}\). That is the time-domain story. To bring in the frequency domain, we first need to look at the sampling operation from a slightly different angle.
Sampling as multiplication#
Here is a subtly different way to think about sampling. Instead of “reading off” values on a grid, imagine multiplying the continuous signal \(x(t)\) by a peculiar function that is 1 exactly on the sampling grid and 0 everywhere else. This function is called an impulse train:
Multiplying our signal by this comb zeroes out everything between the sampling instants, while preserving the signal’s value exactly at each instant \(t = n/f_s\). In other words, sampling can be viewed as multiplication by an impulse train:
The figure below shows this in the time domain, using the running example \(x(t) = \sin(2\pi t) + \sin(2\pi 2 t)\). The continuous signal (left) is multiplied by an impulse train (middle) to produce a sampled signal (right) that is nonzero only on the grid.
Fig. 31 Sampling as multiplication in the time domain. The running example \(x(t)\) (a sum of a 1 Hz and a 2 Hz sinusoid) is multiplied by the impulse train \(\text{Ш}_{f_s}(t)\) to give the sampled signal \(x_{f_s}(t) = x(t)\cdot\text{Ш}_{f_s}(t)\).#
The frequency-domain view of sampling#
Why bother reframing sampling as a multiplication? Because it lets us apply the Fourier transform. Recall from Chapter 5 that the Fourier transform associates any time-domain signal \(x(t)\) with a unique frequency-domain representation \(X(\omega)\). Crucially, the Fourier transform makes no assumption that \(x(t)\) is continuous or smooth. It only requires that the signal be defined across all of \(\mathbb{R}\). Our sampled signal \(x_{f_s}(t)\), spiky and discontinuous as it is, still has a perfectly well-defined frequency domain spectrum via the Fourier transform.
So what is the spectrum of the sampled signal? We’ll skip the calculus and show the result in the bottom row of the figure below. Multiplying by the impulse train in the time domain has the effect of copying the original spectrum \(X(\omega)\) around every integer multiple of the sampling rate \(f_s\). Where the original signal had frequency content only near zero, the sampled signal has infinitely many copies of that content, evenly spaced at \(0, \pm f_s, \pm 2f_s, \ldots\)
Fig. 32 Sampling as multiplication, viewed in both domains. Top (time): the running example \(x(t)\) times the impulse train \(\text{Ш}_{f_s}(t)\) gives the samples \(x_{f_s}(t)\). Bottom (frequency): the spectrum \(|X(\omega)|\) (spikes at \(\pm 1\) and \(\pm 2\) Hz) is replicated around every integer multiple of \(f_s\), producing \(|X_{f_s}(\omega)|\). (All spectral amplitudes are drawn at 1 for clarity.)#
Definition 20 (Frequency-domain consequence of sampling)
Sampling a signal at rate \(f_s\) replicates its spectrum at every integer multiple of \(f_s\). If \(x(t)\) has spectrum \(X(\omega)\), then the sampled signal \(x_{f_s}(t)\) has spectrum
Note
Why does multiplication in time produce copies in frequency? Multiplying two signals in the time domain corresponds to an operation called convolution in the frequency domain, and convolving a spectrum with a comb of spikes slides a copy of the spectrum to each spike. We will study convolution properly when we cover filtering in Chapter 9. For now, the key takeaway is just the result: sampling creates infinitely many copies of the spectrum, spaced \(f_s\) apart.
The widget below draws those copies for a signal whose bandwidth you control. Drag the sample rate down, or widen the band, and watch the neighbors close in on the original.
Drag \(f_s\): the red baseband is the signal’s own spectrum, and the blue copies are the ones that sampling adds at every multiple of \(f_s\). The gold dashes mark \(\pm f_s / 2\). Lower \(f_s\), or widen the band with \(f_{\max}\), until the copies run into the baseband.
What this means in practice#
We can now view the whole analog-to-digital and digital-to-analog pipeline in terms of the frequency domain. Analog-to-digital conversion (ADC) takes a continuous sound \(x(t)\), multiplies it by an impulse train to produce samples \(x_{f_s}(t)\), whose spectrum \(X_{f_s}(\omega)\) consists of the infinite copies we just described:
Fig. 33 Analog-to-digital conversion. The continuous sound \(x(t)\) is sampled into \(x_{f_s}(t)\), whose spectrum \(X_{f_s}(\omega)\) is the original spectrum replicated at every multiple of \(f_s\).#
Digital-to-analog conversion (DAC) has to run this backwards. From the copied spectrum \(X_{f_s}(\omega)\), it must isolate the original spectrum \(X(\omega)\) (using a filter to discard the copies), and from that reconstruct the original sound \(x(t)\):
Fig. 34 Digital-to-analog conversion. A filter isolates the central copy \(X(\omega)\) from among the copies, discarding the rest, and the continuous sound \(x(t)\) is reconstructed from it.#
This leads to the key insight at the heart of sampling:
Important
As long as we can perfectly identify and isolate the original spectrum \(X(\omega)\) among the shifted copies in \(X_{f_s}(\omega)\), we can perfectly reconstruct \(x(t)\) from the sampled version \(x_{f_s}(t)\).
This should feel surprising. Sampling is obviously throwing information away. It records the signal at a handful of instants and discards everything in between. In fact, infinitely many different continuous signals pass through the exact same samples. The figure below shows two sinusoids at 1 and 2 Hz that both cross zero at every integer, so sampled at \(f_s = 1\) Hz they yield identical (all-zero) samples:
Fig. 35 Two different continuous signals that share identical samples. At \(f_s = 1\) Hz, both sinusoids are sampled at their zero crossings, so from the samples alone we cannot tell them apart.#
Given that many signals share the same samples, it stands to reason that perfect reconstruction from samples can only work under the right conditions and assumptions. Understanding exactly when we can isolate the original spectrum is the heart of sampling theory.