# Sampling Theorem illustration

Can someone please explain the illustration (figure 1.19) at the bottom of this image? It looks like there are four sampling points but I don't understand what the different curves represent. Actually except from the dashed curve I can't even distinguish the different curves from each other. Can someone please clarify this so that the illustration makes sense? (Image source: Digital Signal Processing Principles Algorithms and Applications)

• Nitpick: I think it's better to add "reconstruction/interpolation" to the title in order to make it easier for other people to find. – jojek Sep 5 '15 at 13:54

This plot depicts how to convert your digital signal back to the analog one, using $\mathrm{sinc}$ functions. The nice property of these functions used in this process, is that maximum of each function always occurs at minimums of the other, shifted function: Now the process of the D/A conversion that is depicted on your plot is basically taking a $\mathrm{sinc}$ function, and multiplying it by one sample that is at the maximum of $\mathrm{sinc}$. You do it for each and every sample of your digital signal, and then sum all of the outputs. For example, for the above plot, the outcome would be following: Now maybe some more complicated example of D/A conversion. On the plot below, you can see the actual samples (in blue) and "analog" $\mathrm{sinc}$ interpolated signal (in red). Plotting each function separately you can observe what will become an analog signal later: I hope that it is more intuitive for you now. In order to complete this example, here is some MATLAB code I used:

clc, clear all, close all
fs = 32;
dt = 1/fs;

% Generate a samples of the signal
ts = linspace(0, 1, 10);
s = 2*sin(2*pi*ts) + sin(2*pi*3*ts);

td = linspace(0, (length(s)-1)*dt,     length(s));
t  = linspace(0, (length(s)-1)*dt, 100*length(s));

sincM = repmat( t, length(td), 1 ) - repmat( td', 1, length(t) );
SS =  s* sinc( sincM/dt );

% Sampled signal
stem(td, s, 'b', 'linewidth', 2)
hold on
% Reconstructed signal
plot(t, SS, 'r', 'linewidth', 2)
grid on

legend({'sampled signal', 'interpolated signal'})

figure
stem(td, s, 'b', 'linewidth', 2)
hold on
grid on
% Each sinc function
basis = sinc(sincM/dt)';
sbasis = bsxfun(@times, basis, s);
plot(t, sbasis)


It is difficult to make out but it looks like 4 copies of the interpolation function (sinc function from 1.4.22) weighted by the sample values, and drawn at each point from (n-2)T to (n+1)T.

The sum of all these sinc functions weighted by the sample value (1.4.23) is the original signal. That is, if you add up all the solid black line functions, you get the dotted line.

The sampling theorem says that you can reconstruct your signal, using a low pass filter. For an ideal low pass filter, in time domain we have sinc functions, that is the equation 1.4.22. So, in the time domain, you have the convolution between this sinc function and your samples. The samples are represented as kronecker deltas, so the convolution result is the sum of the sinc functions shifted in the samples time positions (Eq 1.4.24).

This shifted sinc functions you can see as a solid line in the graph. The dashed curve are the reconstructed signal, the sum of the sinc functions.

I know it's difficult to see the sinc functions in the graph, but use your imagination (I presume that you know what is a sinc function).

The explanation given in your text is, unfortunately, quite dreadful and confuses several issues. We have a low-pass function $x(t)$ whose sample values $$\cdots, x((n-2)T), x((n-1)T), x(nT), x((n+1)T), \cdots$$ are given to us. Note the complete absence of any subscript $a$ on $x$. We write $x_n$ for the $n$-th sample value $x(nT)$. We wish to reconstruct $x(t)$ from its samples, and our reconstruction is $x_a(t)$ as (incorrectly) defined in (1.4.23): the correct definition is $$x_a(t) = \sum_{n=-\infty}^\infty x(nT)g(t-nT) = \sum_{n=-\infty}^\infty x_n g(t-nT).\tag{1.4.23.corrected}$$ Note again the complete absence of any subscript $a$ in the middle sum, and the right-hand sum emphasizes that the reconstruction is a weighted sum of delayed versions of $g(t)$ with the weights being the given sample values.

The function $x_a(t)$ as defined in $(1.4.23.\text{corrected})$ has the property that if $t=mT$, then $$x_a(mT) = \sum_{n=-\infty}^\infty x_ng(mT-nT) = \sum_{n=-\infty}^\infty x_n g((m-n)T) = x_m \tag{1}$$ because $g(t)$ is a Nyquist pulse and enjoys the property that $g(\ell T) = 0$ if $\ell$ is a nonzero integer while $g(0) = 1$. Thus, the reconstructed function $x_a(t)$ has the property that at each sampling instant $mT$, the value of $x_a(t)$, viz. $x_a(mT)$ equals $x_m$, the $m$-th sample value given to us. Thus, as far as samples are concerned the two functions $x_a(t)$ and $x(t)$ have the same values at the sampling instants $mT$. In other words, $$x_a(t) = x(t) \quad \text{for} \quad t = mT, m \in \mathbb Z.\tag{2}$$ Note that $(2)$ holds regardless of what $T$ is and how it relates to the maximum frequency in $x(t)$ etc.

What at time instants other than multiples of $T$? Is it true that $x_a(t)$ as defined in $(1.4.23.\text{corrected})$ equals $x(t)$ for all $t, -\infty < t < \infty$? Well, that is where the fun statrts. If the Nyquist criterion is met, then $x_a(t)$ as given in $(1.4.23.\text{corrected})$ is precisely the $x(t)$ that we wish to recover. I will not prove this statement (which is called the Nyquist theorem or the Shannon-Whittaker sinc interpolation formula etc) but that $x_a(t)$ as defined in $(1.4.23.\text{corrected})$ is $x(t)$ is what the crux of the matter is. If the Nyquist criterion is not met, then $(1.4.23.\text{corrected})$ gives a function $x_a(t)$ whose sample values $x(t)$ at the sampling instants $mT$ (cf. the remarks surrounding $(1)$ and $(2)$ above) but is not equal to $x(t)$ at other times. In fact, $x_a(t)$ is the result of aliasing of $x(t)$ with respect to the sampling frequency etc, but that is a matter for a different question.

With that as preliminaries, let us turn to the illustration that puzzles you. The dashed curve is the result of the interpolation: the function $x_a(t)$ as defined in $(1.4.23.\text{corrected})$ and it is the sum of infinitely many weighted and delayed sinc functions. The other curves are (four of the) infinitely many sinc functions $x_m g(t-mT)$ on the right side of $(1.4.23.\text{corrected})$. At $t=nT$, the term $x_ng(t-nT)$ which occurs on the right side of $(1.4.23.\text{corrected})$ has a peak value of $$x_ng(nT-nT) = x_ng(0) = x_n$$ and it has value $0$ at other sampling instants $\cdots, (n-2)T, (n-1)T, (n+1)T, \cdots$ Similarly, the function $x_{n-1}g(t-(n-1)T)$ has value $x_{n-1}$ at $t=(n-1)T$ and value $0$ at all other sampling instants. In short, if we evaluate the sum $$\sum_{m=-\infty}^\infty x_m g(t-mT)$$ at $t=nT$, that sum of infinitely many terms simplifies to $x(nT)$ because all the other terms are $0$. No muss, no fuss, no worries about convergence of an infinite series etc. Remember that all this holds without any issues of Nyquist criteria etc. The hard part is the assertion that $x_a(t)$ as defined in $(1.4.23.\text{corrected})$ equals $x(t)$ for all $t$ if the Nyquist criterion is satisfied.

So why all this yelling and screaming about (1.4.23) being incorrect and the explanation in the text being sheer nonsense? Well, (1.4.23) as shown in the OP's text has sample values of $x_a(t)$, the reconstructed signal, on the right side. So, the definition is circular, to say the least, and even if we ignore that, it is an assertion of the Nyquist theorem or the Shannon-Whittaker interpolation formula without any proof. The equality (1.4.23) as given in the text holds at $t=mT, m \in \mathbb Z$; the assertion that it holds for all $t$ is a proof by intimidation.

• Oh, goody! A down-vote without a comment. – Dilip Sarwate Sep 6 '15 at 3:07