I have a question concerning the distribution of noise in the frequency domain in case of Coherent Sampling. I read up about Coherent Sampling and understood that in order for a frequency $f_{in}$ to be located on one single bin of the DFT, the period or a multiple of it must fit exactly into the data window of the DFT, meaning that the following must be true:

$$ \frac{f_{in}}{f_s}=\frac{N_c}{N} $$ $N$ ... Record Length, $N_c$ ... Number of cycles in data window

Furthermore in the slides of a course about Mixed-Signal Processing I am attending it is mentioned that $N_c$ and $N$ need to be coprime in order for the quantization noise to be distributed uniformaly. Otherwise the quantization noise would show a discrete spectrum. Why is that the case?


2 Answers 2


This is most easily understood by examining the error between the true sinusoid and the quantized sinusoid. Let's start by defining a simple sinusoid. For simplicity, I will assume a cosine, but the same arguments apply for a sinusoid with an arbitrary phase offset. The true sinusoid is defined in continuous-time as

$$ x(t) = \cos\left(2 \pi f_{in} t\right). $$

Now, we need to sample this signal with a period of $T_s = \frac{1}{f_s}$ to obtain a discrete-valued (but unquantized) signal

$$ x_D(n T_s) = \cos\left(\frac{2 \pi f_{in} n}{f_s}\right).$$

Using the relationship that you provided in your question, we can rewrite this as

$$ x_D(n T_s) = \cos\left(\frac{2 \pi N_c n}{N}\right). $$

From this it should be clear that this signal lies in two bins, specifically the bins at $N_c$ and $N - N_c$ of an $N$ point FFT. However, this signal is not realizable with finite precision numbers. So, we need to quantize it. Let us assume that we are quantizing to $q+1$ bits using two's complement. A reasonable approximation to the quantized signal is given by

$$ x_Q(n T_s) = 2^{-q} \left\lfloor 2^{q} \cos\left(\frac{2 \pi N_c n}{N}\right) \right\rfloor.$$

Another way to represent this would be to represent the sinusoid added with an error term (i.e., the quantization noise $\epsilon_q(n T_s)$). This is captured in the following:

$$ x_{D}(n T_s) = x_Q(n T_s) + \epsilon_q(n T_s). $$

Now, let's consider what $\epsilon_q(n T_s)$ looks like for the two cases you mentioned. That is, the coprime case and the common factor case. Let's rearrange this slightly so that we can see things a little better,

$$ \epsilon_q(n T_s) = \cos\left(\frac{2 \pi N_c n}{N}\right) - 2^{-q} \left\lfloor 2^{q} \cos\left(\frac{2 \pi N_c n}{N}\right) \right\rfloor. $$

Now, consider the case where $N_c$ and $N$ share a common factor, $M$. Let's say $M$ is the greatest common factor. In this case, $N_c = M K_c$ and $N = M K$. Using this and the expression derived for $\epsilon_q(n T_s)$, we can show that

$$ \epsilon_q(n T_s) = \cos\left(\frac{2 \pi K_c n}{K}\right) - 2^{-q} \left\lfloor 2^{q} \cos\left(\frac{2 \pi K_c n}{K}\right) \right\rfloor, $$

and from this, we can see that

$$ \epsilon_q(n T_s) = \epsilon_q(n T_s + K T_s) $$


$$ \cos\left(\frac{2 \pi K_c n}{K}\right) = \cos\left(\frac{2 \pi K_c (n + K)}{K}\right).$$

In other words, the sequence is periodic with period $K < N$ since $K$ and $K_c$ are coprime. This means that all of the information in this signal can be captured with a $K$ point FFT. This, in turn, means that all of the energy from this signal is contained at the equivalent bins in the $N$ point FFT. These are the bins at $0, M, 2M, ... (K-1)M$. All of the other bins are zero-valued. This is why you see a discrete spectrum as shown in the slides you mentioned.

Now, if $N$ and $N_c$ are coprime, then the sequence is non-sinusoidal and aperiodic (or viewed another way, it is periodic with period $N$). There is no shorter period embedded in the sequence as there was with the common factor case. Therefore, all bins are required to represent the signal.

  • $\begingroup$ Thank you for your answer @hops . Two question though: I understood from your explanation that by having a common factor, the sequence turns out having a smaller period K instead of N. The FFT anyway calculates N points. But why do the K bins get scaled by $M$ to $0, M, 2M, ... , (K-1)M$? In your last formula, if $n<K$, sampled values of the cosine are received, if $n\geq K$, then those values repeat itself. You say that this doesn't happen because only at K bins the signal energy is contained. Why? $\endgroup$ Jan 3, 2017 at 11:00
  • $\begingroup$ Answer to question 1: This is what happens when you keep the sampling rate the same and extend the FFT length, you get a finer frequency resolution over the same bandwidth. You are dividing the same bandwidth into $K$ frequency bins or $N$ frequency bins (when you are considering a $K$ point or $N$ point FFT respectively). Recall that $N/K = M$. so, we have divided the spectrum into $B / N$ bins and $B / K$ bins respectively. $B$ being the bandwidth. This is why the center frequency of the bins appears "scaled" by $M$ in the discrete spectrum. $\endgroup$
    – hops
    Jan 3, 2017 at 16:11
  • $\begingroup$ I'm not sure I'm clear on question 2. Please clarify. I am saying that the points in the cosine and the quantized cosine repeat with a period of $K$ because we are evaluating them at the same points after $K$ samples. Is that what you are asking? Or are you asking why a signal that is periodic in $K$ samples only requires sine/cosines that are at discrete frequencies of $2 \pi k / K$ with $k = 0, 1, ... K-1$. The answer is closely related to Fourier Series, but is beyond the scope of this comment and your question. Ask a new question and I'll try to answer it if no one else does. $\endgroup$
    – hops
    Jan 3, 2017 at 16:18

In addition to the good answer from hops, have a look at the following python code, which can illustrate this behavior:

Fs = 700.0
T = 1.
N = Fs*T
f0 = 5# change to something else, how you want
Nc = f0*T
t = np.arange(0, T, 1/Fs)
signal = np.sin(2*np.pi*f0*t)

print N, Nc

B = 2 # number of bits used for quantization
A = 1. # (one-sided) amplitude

delta = (2*A) / (2**B-1)
threshs = -A + delta * np.arange(2**B)

def quantize(signal, threshs):  
    # performs the quantization (for newer python version, you can have a look at numpy.digitize)
    T = threshs.reshape((1, -1))
    S = signal.reshape((-1,1))
    diff = S - T

    quantized = threshs[np.argmin(abs(diff), axis=1)]
    return quantized

quantized = quantize(signal, threshs)
qnoise = quantized - signal

plt.plot(t, signal)
plt.plot(t, quantized, 'r-')
plt.title('Fs=%.0f, f0=%.0f, N=%.1f Nc=%.1f' % (Fs, f0, N, Nc))
plt.plot(t, qnoise, 'g-')

f = np.linspace(-Fs/2, Fs/2, len(t), endpoint=False)
spec = lambda x: 20*np.log10(abs(np.fft.fftshift(np.fft.fft(x))))
plt.plot(f, spec(signal), label='signal')
plt.plot(f, spec(qnoise), label='noise')
plt.xlim((0, Fs/2))
plt.ylim((-50, 100))

Here are two outputs, for different Fs:

enter image description here

enter image description here

As visible, the peak for the 5Hz signal is very clear, for both sampling frequencies. But, the noises look different. When N and Nc are not coprime, the noise is quite discrete (i.e. it shows strong peaks), but still, it is distributed everywhere in frequency domain. Looking at the coprime example (5 and 573), we see a bit more distributed noise, but still it exhibits strong peaks in the frequency domain.

Looking at the time-domain realization of both noises, it can be seen that both exhibit a decent periodicity. This periodicity creates the peaks in the frequency domain, regardless of whether the signal contains a full period of the noise or not.

So, with the above results, I would actually question the mentioned slides, which state the noise is uniformly distributed in the frequency domain. It is not, as any periodic time-domain signal will create periodic quantization noise, and hence create a (roughly) discrete noise spectrum.

Edit: This is the result with 16 bit quantization (i.e. B=16):

enter image description here

enter image description here

As visible, the effect is very different from the coarse quantization with 2bits above: For coprime numbers, the noise looks uniformly distributed. For matching numbers, the noise becomes discrete in frequency domain. This confirms the OPs claim. So, it depends strongly on the number of bits used for quantization.

Edit2: I have just increased the frequency of the signal to 250Hz. Now N=700 and Nc=250 (which are not coprime, both dividable by 50), the spectrum of the noise is still relatively uniform, but has some small peaks. So, the claim from the OP is really depending on the actual parameters. Only coprime-ness seems not to be sufficient. Anyway, it's an interesting thing to play around with.

enter image description here

  • 1
    $\begingroup$ I don't have time to look at this too closely, but I will later tonight. What are the red lines supposed to be? The quantized signal? It looks like you are quantizing to 2 bits (4 levels)? I bet you won't see such strong harmonic behavior if you quantize to say 14 or 16 bits. It would be interesting to see that. $\endgroup$
    – hops
    Jan 2, 2017 at 15:44
  • $\begingroup$ The red signal is the quantized signal, with 2bits quantization. I've added figures for 16bits quantization. There, the claims of the OP seem to hold. $\endgroup$ Jan 2, 2017 at 16:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.