Sampling Theorem -- Aliasing

The sampling theorem is the most important idea in digital signal processing. It is the reason we can use digital computers to analyze and manipulate continuous time signals.

The sampling theorem consists of two separate ideas: The first is aliasing, the concept that different continous time signals can result in the same discrete time signal. The second idea is reconstruction, that if the sampling rate is sufficiently high, the continuous signal can be reconstructed exactly (or at least with high accuracy) from the discrete time signals.

This posting is about aliasing. We will look at reconstruction in a later posting.

In [38]:
%pylab inline
Populating the interactive namespace from numpy and matplotlib

1. Simple Aliasing

A simple example of two sinusoids aliasing to the same digital signal.

In [39]:
T=1 #sampling period
t = linspace(0,8,801) #for the continuous time signals
n = arange(0,9) #discrete time 

f1 = 0.3
f2 = 1.3

w1 = 2*pi*f1
w2 = 2*pi*f2

y1 = cos(w1*t)
y2 = cos(w2*t)

plot(t,y1, t,y2)
scatter(n,cos(2*pi*f1*n),marker='x')
scatter(n,cos(2*pi*f2*n),marker='4')
Out[39]:
<matplotlib.collections.PathCollection at 0x10e57d2d0>

The two scatter plots are on top of each other, showing that sampling the two continuous time sinusoids results in the same discrete time signal.

2. Negative frequencies

A positive frequency can alias to a negative frequency and result in the same samples.

In [40]:
f3 = 0.6
f4 = -0.4

w3 = 2*pi*f3
w4 = 2*pi*f4

y3 = cos(w3*t)
y4 = cos(w4*t)

plot(t,y3,t,y4)
scatter(n, cos(2*pi*f3*n))
Out[40]:
<matplotlib.collections.PathCollection at 0x10e5866d0>

Notice the samples are at the intersections of both sinusoids.

To get the same samples, we have to assure the frequencies and phases match. Here's an example with the same digital frequencies, but the samples differ because the phase isn't right.

In [41]:
f3 = 0.6
f4 = -0.4

w3 = 2*pi*f3
w4 = 2*pi*f4

y3 = cos(w3*t)
y4 = sin(w4*t)

plot(t,y3,t,y4)
scatter(n, cos(w3*n),marker='x')
scatter(n, sin(w4*n))
Out[41]:
<matplotlib.collections.PathCollection at 0x10eb3c050>

Here we plot two sinusoids at the same frequency, w3, but at different phases and the two sets of samples. Note the samples intersect the sinusiods even though the original sinusoids were at two different frequencies, f3 and f4. This shows that the digital frequencies are the same even though the phases differ.

In [42]:
plot(t,cos(w3*t),t,sin(w3*t))
scatter(n, cos(w3*n),marker='x')
scatter(n, sin(w4*n))
Out[42]:
<matplotlib.collections.PathCollection at 0x10eb6f950>

Charles Boncelet, 17 August 2014