# From a physics perspective, why does D/A quantization error result in a noise floor?

For the last week or so I have been trying to understand how quantization error results in the noise floor outside of a mathematical perspective and I haven't really had any luck finding a source that discussed quantization noise without using equations to show where quantization error comes from. I certainly have nothing against using math proofs but I was hoping to understand why quantization noise existed rather than how to calculate it. I think I’ve been able to work through it but I was hoping someone would be able to double check my work or point me in the right direction if I’m missing something.

So here is how I figure it so far: Because the sample rate is allowing us to have a perfect recreation of the frequency of the wave the bit depth only determines the range of values available for the amplitude of a wave being converted to a digital signal.

When the original signal gets rounded to the nearest bit it creates slight changes in the amplitude which result in a slightly altered waveform at each sample. This new waveform is basically the same as the sum of our original signal and a new frequency. So if we were to duplicate this in an analog signal we could do it by adding additional frequencies at very small amplitudes to our signal 44.1 thousand times a second (or whatever the sample rate is). The lower the bit depth the bigger these changes to our original waveform will be, and so the larger the amplitude of the added waves will be raising the “noise” floor.

If you sampled a waveform that allowed for a slower sample rate, say sampling a 10 Hz wave 20 times a second. Instead white noise as a result of quantization error would you hear a quick succession of random frequencies paired with your original wave (which would obviously be to low to hear)?

If you can follow my logic up to this point I have one additional question because in my tests changing the phase of my sampled analog wave doesn't seem to change the frequencies of the quantization error like I thought it would. Am I making a mistake in my test?

For the last week or so I have been trying to understand how quantization error results in the noise floor outside of a mathematical perspective and I haven't really had any luck finding a source that discussed quantization noise without using equations to show where quantization error comes from.

That's because it's a purely mathematical effect, there's no physics involved.

It's technically quantization distortion, not noise, but we simplify the analysis by treating it as a noise source.

But it's really not; it's nonlinear distortion, so the spectrum of the quantization error varies with the signal. Maybe that's where you're confused?

For instance, if you sample a sine wave that's a sub-multiple of the sampling rate and quantize it:

you will get harmonic distortion only at specific frequencies:

If it's not an exact sub-multiple, the infinite number of harmonics produced by the distortion will alias and produce a more noise-like residual:

Since this sort of behavior is more common with arbitrary signals, it's usually treated like a noise source. In addition, we usually randomize this distortion by adding a small amount of dither noise to the analog signal before quantization, which flattens out the spectrum, reducing the peak value of the distortion and making the noise unrelated to the signal, so we are actually forcing it to be a true noise source rather than a distortion:

from __future__ import division
from numpy import linspace, round, abs, sin, log10, pi
from numpy.fft import rfft
from numpy.random import randn
from scipy.signal import hamming as window
import matplotlib.pyplot as plt

fs = 5000  # Hz
t = linspace(0, 1, fs, endpoint=False)
f = 25  # Hz
x = sin(2*pi*f*t)
plt.figure(1)
plt.plot(x)
plt.figure(2)

x += randn(fs)/20  # Dither
x = round(x*5)/5  # Quantization

plt.plot(20*log10(1/fs * abs(rfft(window(fs)*x))))
plt.ylim(-100, 0)
plt.figure(1)
plt.plot(x)
plt.margins(0, 0.1)

• somehow I had never realized (or forgot) that quantization is non-linear (and, I guess, time-varying). I wrote four lines of Matlab (code here) to show the harmonic distortion, and it's definitely there! It's cool; thanks for pointing it out. – MBaz Dec 3 '14 at 23:59
• @MBaz I think it would be considered time-invariant, since the same input always produces the same output. – endolith Apr 23 '17 at 15:20
• But, if you time-shift the input while leaving the sampling instants fixed, then the output is different (not time-shifted by the same amount), right? That's why I think it's time-variant. – MBaz Apr 23 '17 at 19:01
• @MBaz well quantization and sampling are separate things, you can theoretically have each without the other – endolith Apr 24 '17 at 1:30
• I agree -- quantization by itself is time invariant. – MBaz Apr 24 '17 at 1:52

Quantization error is usually modeled as additive white noise, uniformly distributed over the interval $[-\delta/2, \delta/2)$, where $\delta$ is the step size that the signal is quantized to. As you described, the quantized signal model is described by:

$$s_Q[n] = s[n] + w[n]$$

where $s[n]$ is the original signal and $w[n]$ is a white noise process that models the act of quantizing $s[n]$ to the nearest value $s_Q[n]$. That is, the quantization noise is modeled as if it was a source that added a small value to each sample, such that the result is a multiple of the quantization step size.

The white noise assumption merely states that the quantization error in an arbitrary sample $n$ is independent of the quantization error in all other samples. The validity of this assumption varies from application to application, but it's typically taken to be true.

Since the noise is assumed to be white, its corresponding power spectral density is flat. This creates the flat "noise floor" that you typically see.

to answer the "why" question, i would say that although quantization error, without dither, is solely deterministic (and that determinism shows up when the signal amplitude is nearly as small as the quantization step-size), when the signal amplitude is much larger than the quantization step-size and the signal is arbitrary, then the quantization error (sometimes called "rounding error") is quite unpredictable within the limits of the step size.

pick an arbitrary (but reasonably large) real-number and round it to the nearest integer. the quantization error is the difference of the rounded value from the original unrounded value. that number can be anything between -1/2 and +1/2 with nearly equal probability. so we model that error as a uniform p.d.f. random number in that range that is independent from the rounding error of all previous and future samples. (when the signal is very small in amplitude, the assumption that the random value of the rounding error is independent of the other rounding errors is not valid, but if the signal is very large, it's not a bad assumption.)

The physics interpretation has to do with the sources for noise. In my experience, if the analog portion of the electronics is "clean", the limiting factor is quantum. Ultimately, you are counting electrons or photons. This gives you a Poisson distribution with standard deviation of the number of particles you are counting. That's the noise floor.

If the electronics is not perfectly clean, it will pick up stray energy. This may be a fluctuation on the zero or full scale reference on the A/D converter. Or, it may have something to do with the detector/transducer. Or it could be longer term variation in the gain of a circuit leading to the A/D, often caused changes in temperature. Or, the detector itself may have a bias that fluctuates.

In my line of work, I often deal with detectors of light. These will often "mistake" a photon of heat for a photon of visible light. They call this dark current. Stray light can also be an issue... catching light that we didn't want to catch.