# Nyquist-Shannon Sampling Theorem

Nyquist-Shannon Sampling Theorem

The Nyquist-Shannon Sampling theorem is a fundamental one providing the condition on the sampling frequency of a band-width limited continuous-time signal in order to be able to reconstruct it perfectly from its discrete-time (sampled) version. It stated that the sampling frequency must be at least two times the highest frequency of the continuous-time signal spectrum.

## What is a Signal?

What is a Signal?

A signal is a time/space varying function which includes some useful information. Most of signals are continuous-time ones and hence can not be either stored (or transmitted) over realistic limited data storage (or band-limited propagation space) due to infinity of points to be processed.Such signals could be of different sources or types, such as audio ones, or any real life physical measure or parameter retrieved by sensors (temp, humidity, speed, ...).

◼

Example of a continuous-time* signal - Mean Temperature during 2016 in Rabat, Morocco:

In[38]:=

weatherData=WeatherData[{33.9716,6.8498},"MeanTemperature",{{2016,1,1},{2016,12,31},"Day"}];

DateListPlot[weatherData,Joined->True]

Out[39]=

In order, to process real life signals either to store or transmit, we need to a sampling process them, making them discrete-time signal.

## Sampling Theorem

Sampling Theorem

Sampling a continuous-time signal is getting one sample each sampling period , which means a sampling frequency equivalent to .The mean important decision to make is the sampling frequency value of

: Indeed, if its value is too big, we’ll get samples per second, so large storage or large band width in order to transmit the data. If on the other hand, the value is too small, we won’t be able to reconstruct the signal from the samples.Hence, there is a tradeoff to make in order to minimise the needed resources (storage or frequency band-width) while being able to reproduce the original signal from the samples.

T[s]

s

f=[Hz]

s

1

T

s

f

s

f

s

One theorem provides an answer to this question, it’s the Nyquist-Shannon Sampling Theorem which states:

A continuous-time signal can be sampled at a frequency in order to get a discrete-time copy of it , and afterwards be reconstructed perfectly to its original form if with is the maximum frequency value of the signal spectrum

x(t)

f

s

x[n]

x(t)

f>2f

s

max

f

max

x(t)

Next, we’ll consider a function and see what happen to the sampled signal on the frequency domain using Fourier Transform

Sinc

2

## Sampling Process

Sampling Process

### Time Domain Analysis

Time Domain Analysis

Consider the function which represent a continuous-time signal.

x(t)=Sinc(t)

2

◼

Plot of the signal :

x(t)=Sinc(t)

2

In[40]:=

x[t_]:=(Sinc[Pi*t])^2;

Plot[x[t],{t,-2,2}]

Out[41]=

Consider a sampling frequency and let see what happen for different values of

f

s

f.

s

◼

Plot of the continuous-time and discrete-time (sampled) signals:

In[42]:=

Manipulate[

Show[DiscretePlot[x[t],{t,-3,3,1/fs},PlotRange{{-3,3},{-0.1,1.1}},PerformanceGoal"Quality",

PlotStyleDirective[Orange,Thick],PlotMarkersAutomatic],Plot[x[t],{t,-3,3}]],{{fs,15.25,

"Frequency "},0.5,30,Appearance"Labeled"},SaveDefinitionsTrue]

f

s

Out[42]=

As we can see, for high values of we can at least recognize visually the original continuous-time form on the signal. However, for small values of such as for instance, we can no more visually retrieve the form of the original function, with only four sample over the 20 interval duration it’s quite impossible to go back from samples to continuous signal. Indeed, in such case, we are sure not satisfying the Nyquist-Shannon sampling condition.In the time domain, we can somehow visually understand what’s happening, however, the theorem is more understandable when analyzed on the frequency domain.

f

s

x(t)

f

s

f=0.1hz

s

Sinc

2

### Frequency Domain

Frequency Domain

The spectrum analysis of signal allows us to understand easily and even prove the theorem ourselves.

x(t)

TFSinc(at)=tri

2

1

a

f

a

◼

Fourier Transform of the signal :

x(t)

In[43]:=

Simplify[FourierTransform[x[t],t,ω]]

Out[43]=

-2ωSign[ω]+(-2π+ω)Sign[-2π+ω]+(2π+ω)Sign[2π+ω]

4π

2

3/2

◼

Spectrum of the signal :

x(t)

In[44]:=

Plot[FourierTransform[x[t],t,ω],{ω,-10*2Pi,10*2Pi},PlotRange{{-2*2Pi,2*2Pi},{0,0.41}}]

Out[44]=

◼

Sampled signal (left) and its Fourier transform spectrum:

x[n]

In[45]:=

Manipulate[Row[{DiscretePlot[x[t],{t,-3,3,1/fs},PlotRange{{-3,3},{-0.1,1.1}},PerformanceGoal

"Quality",PlotStyleDirective[Orange,Thick],PlotMarkersAutomatic,ImageSize340],

ListLinePlot[Join@@Table[Abs[Fourier[Table[N[x[n/fs]],{n,-4*fs,4*fs+1}]]],4],DataRange{-4Pi,4Pi},

PlotRange{{-4Pi,4Pi},{0,1.5}},ImageSize300]}],{{fs,15.25,"Frequency "},0.5,20,Appearance

f

s

"Labeled"}]

Out[45]=

The spectrum of the sampled signal is a periodic form where it’s period is , and as long as we respect the Nyquist-Shannon condition, its form over one period is equivalent to the spectrum of the original continuous-time signal . Indeed, while the sampling frequency

is large enough, there is no overlapping between the periods of the spectrum, and then, the original signal can be retrieved by mean of a low passband filter. However, if the sampling frequency is too low, such as 1.4 in the above example, there will be overlapping of the spectrum, which we call an aliasing effect. In such a case, we can no more retrieve the original signal using a simple low-passband filter, and we need then a more powerful signal processing by means of equalization. The condition to avoid the overlapping is that , which represents perfectly the Nyquist-Shannon sampling theorem.

2π

x(t)

f

s

f=<

s

f>2f

s

max

* The signal looks continuous on the plot but any signal processed (transmitted, stored or displayed) is always a sampled version of the original continuous time parameter

## Reconstruction Process

Reconstruction Process

The reconstruction process consists in the generation of the original continuous-time signal from the sampled version . As long as there is no aliasing effect, a simple low passband filter is enough to retrieve the original signal

x(t)

x[n]

◼

Filtering the Spectrum of the sampled signal :

x[n]

In[85]:=

Manipulate[Show[ListLinePlot[Join@@Table[Abs[Fourier[Table[N[x[n/fs]],{n,-4*fs,4*fs}]]],2],DataRange{-2

Pi,2Pi},PlotRange{{-2Pi,2Pi},{0,1.5}},ImageSize300],Plot[HeavisidePi[x/(2*Pi)],{x,-2Pi,2Pi},

ExclusionsNone,PlotStyleDirective[Orange,Thick,Dashed]]],{{fs,8,"Frequency "},0.5,20,

f

s

Appearance"Labeled"}]

Out[85]=