# Understanding Nyquist rate

I'm starting to learn signal processing, and am trying to understand Nyquist rate a bit better.

From what I understand, if I sample at a rate > Nyquist rate I'm supposed to have no data loss.

I'm testing on $\displaystyle f(t)=\sin(2t\pi)$.

To my understanding, its frequency is $1\ \rm{Hz}$, so the Nyquist rate is supposed to be $2\ \rm{Hz}$.

I tried FFT-ing the same function with sampling rates of $3\ \rm{Hz}$ and $10\ \rm{kHz}$ and got different results: (function + FFT displayed on same plot)  Why are the results different? Doesn't the fact that I'm over the Nyquist rate means that the FFTs are supposed to be the same?

This is the code I used in Octave:

x= [0:1/3:4]
x2 = [0:0.0001:4]
f = sin(2*x*pi)
g = sin(2*x2*pi)
subplot(2,1,1)
plot(x,f,x,fft(f))
subplot(2,1,2)
plot(x2,g,x2,fft(g))

• "if I sample at a rate > nyquist rate I'm supposed to have no data loss". That is not what the sampling theorem says.
– MBaz
Dec 8, 2017 at 22:51
• The book I'm using says "this equation indicates that a continuous, band limited function can be recovered completely from a set of it's samples if the samples are acquired at a rate exceeding twice the highest frequency. This result is known as the sampling theorem". Could you help me understand what I've gotten wrong?
– Lior
Dec 8, 2017 at 22:58
• So, the definition is not "no data loss" (which is meaningless since we're not dealing with "data" here), but "the signal can be reconstructed perfectly". It also doesn't mean that "their FFTs are the same" or "all plots will look nice". I don't mean to sound rude (sorry), it's just that I'm pressed for time -- I hope these small pointers are helpful. This may also help: dsp.stackexchange.com/questions/43563/…
– MBaz
Dec 8, 2017 at 23:33
• When plotting these results you should plot the fft output along with an appropriate frequency vector, and most definitely not the time vector. Also I believe that the fft output also has to be scaled by the data length if I remember correctly. Dec 9, 2017 at 2:10

1) The sampling rate has to be above twice the bandwidth, or twice the highest frequency. The shorter the time you sample, the higher the sampling rate has to be ABOVE 2x highest frequency.

2) The signal has to be strictly bandlimited to at (or within) some frequency range below 0.5 sampling rate for no loss in information during reconstruction to occur. Note that any sharp corners or steep edges in your signal imply an extremely high bandwidth.

Note also that any time-limited signal (e.g. not infinite in duration) has infinite bandwidth, thus will not be strictly bandlimited, so there might always be some error in reconstruction from samples. This error can be reduced to the noise floor by sampling longer at a higher sample rate, which is why (in the real world) one should always use some reasonable margin above the theoretical Nyquist rate (which might be OK for imaginary, perfect, and infinite signals, as written on some chalkboard).

A clear and precise understanding of the Nyquist sampling theorem is only possible by considering the Fourier spectrum of the signal $x_c(t)$ that's being sampled and the respective spectrum of the impulse modulated (sampled) signal $x_s(t)$ : $$x_s(t) = \left( \sum_{k=-\infty}^{\infty} \delta(t-k T_s) \right) x_c(t)$$

whose CTFT is: $$X_s(\omega) = \frac{1}{T_s} \sum_{k=-\infty}^{\infty} X_c(\omega - \frac{2\pi}{T_s} k)$$

The condition of no-aliasing is reflected in the spectrum of $X_s(\omega)$ by no-overlap in the shifted replicas of $X_c(\omega)$. The overlap is determined by two factors:

1- Whether the signal $x_c(t)$ is bandlimited or not; $X_c(\omega)$ has finite support.

2- Whether the frequency shifts $\frac{2\pi}{T_s}$ are large enough to avoid any spectral overlap in the replicas of $X_c(\omega - k\frac{2\pi}{T_s})$.

Note that if the first condition does not hold; i.e., the signal $x_c(t)$ is not bandlimited, then there'll always be aliasing. And if the first condition holds then the second condition describes the allowed range of sampling frequencies as to be larger than twice the bandwidth of the signal $x_c(t)$.

When these conditions hold; i.e., there is no spectral ovrelap, then the continuous time signal $x_c(t)$ is exactly recoverable from its samples $x[n] = x_c(nT_s)$ by the ideal interpolation system.