C9 · Lesson 22 · Quantization and dither
Rounding a signal to a ladder of levels, the noise that leaves, and why adding noise can make it better
Lesson 21 sampled a signal in time and showed when nothing is lost. A converter also rounds each sample to one of levels, and that loses something every time. For a busy signal, the rounding error behaves like a small, flat noise, and the familiar rule of 6 dB per bit follows from it. For a quiet or slowly changing signal it doesn't: the error locks to the signal and becomes distortion, and a signal smaller than one step vanishes entirely. The cure sounds wrong: add a little random noise before rounding. That's dither, and it's why audio, instruments and image processing deliberately add noise.
- A sine wave (dashed) and its quantized version on a ladder of levels across ±1.
- At 3 bits the staircase is coarse and its error is clearly tied to the waveform: it repeats every cycle, which means harmonics, not noise.
- Raise the bits and the steps shrink by half each time. Lower the amplitude below one step and the output stays flat at zero.
Predict
A 12-bit converter's full-scale sine gives the ideal signal-to-quantization-noise ratio. If the sine is reduced to 1/100 of full scale, about what SNR remains, ideally?
The noise stays at while the signal power falls by , 40 dB: 74 − 40 = 34 dB. The SNR formula assumes a full-scale input, and every factor of two below full scale costs a bit's worth, 6 dB. That's why converters are preceded by gain that brings signals near full scale.
Name it
The quantizer
An -bit converter spanning a range has step and rounds each sample to the nearest level. The error lies between and .
Quantization as noise
If the signal crosses many levels in an irregular way, the error is close to uniformly distributed and uncorrelated with the signal, with variance
spread evenly from 0 to . A full-scale sine has power , so its signal-to-quantization-noise ratio is
A real converter adds its own noise and distortion; its measured SINAD defines an effective number of bits, .
When the noise model fails
For a small, slow or periodic signal the error repeats with the signal: it's distortion, concentrated in harmonics. A signal smaller than around a level is rounded to that level every time and disappears.
Dither
Adding random noise before quantizing, about one step peak to peak or more, makes the error independent of the signal. The rounding then varies from sample to sample, the harmonics turn into a smooth noise floor, and the average of many dithered samples recovers values finer than one step. Triangular dither (the sum of two independent uniform noises of ±½ step) removes the dependence of the error's mean and variance on the signal entirely, at the cost of a little more total noise.
Oversampling
Quantization noise spreads over 0 to . Sampling times faster than the signal needs and filtering away everything above the signal band keeps only of the noise: dB better, half a bit per doubling. With dither (or the signal's own noise) to decorrelate the error, averaging buys real resolution.
Worked example
A 12-bit ADC spans 0 to 3.3 V. Find its step, the RMS quantization noise, and the ideal SQNR for a full-scale sine.
Show the solution
- Step.
- RMS noise.
- Ideal SQNR.
- Compare a real part. If the datasheet quotes a SINAD of 62 dB, the ENOB is Two bits are lost to the converter's own noise and distortion.
Answer a step of 0.806 mV, 0.233 mV RMS of quantization noise, and an ideal SQNR of 74.0 dB.
Worked example
A sensor's output is a slow sine of amplitude 0.3 Δ around a level. Without dither, what does the converter report? With ±1 Δ of uniform dither and averaging 1000 samples per reading, how fine is the result?
Show the solution
- Without dither. The signal never reaches a rounding threshold half a step away, so every sample reads the same level: the signal is lost completely.
- With dither. Each sample's rounding depends on the signal plus a random offset, and the average of many readings follows the signal.
- Noise per sample. The dither's rms and the rounding's together make
- Average 1000 samples. Averaging reduces that by : So the 0.3 Δ sine is measured with a resolution about 50 times finer than one step.
Answer without dither the converter reports one constant level and the signal is lost; with dither and averaging, the readings resolve about 0.02 Δ, some 50 times finer than one step.
Worked example
A 10-bit ADC samples an audio-band signal (0 to 20 kHz) at 640 kHz instead of 40 kHz, then filters digitally to 20 kHz. How much does the in-band SQNR improve, and what's the effective resolution?
Show the solution
- Oversampling ratio.
- Noise reduction. The in-band noise falls by two bits' worth:
- New SQNR. as good as an ideal 12-bit converter at the plain rate.
- Going further. Getting much more needs noise shaping, as in the delta-sigma converters of the logic and DSP courses.
Answer the in-band SQNR improves by 12.0 dB, to 74.0 dB, the resolution of an ideal 12-bit converter.
Check
An 8-bit converter spans 3.3 V. What's its step size?
Write units the way you normally would: 1.5 mV, 1500 µV and 0.0015 V are the same answer.
Check
What's the RMS quantization noise of an 8-bit converter spanning 3.3 V?
Write units the way you normally would: 1.5 µV, 1500 nV and 0.0015 mV are the same answer.
Check
An ideal 12-bit converter digitizes a sine whose amplitude is 0.5 of full scale. What's its SQNR in dB?
Check
A converter measures a SINAD of 62 dB. What's its effective number of bits?
Check
A converter oversamples by 16 and filters back to the signal band. Without noise shaping, how many bits of resolution does it gain?
Check
Why does adding dither before a quantizer reduce distortion, even though it increases the total noise?
Check
Quantize a sine with and without dither. With step 1 (so values are in steps), take x = A*sin(2*pi*7*n/1024) for n = 0..1023 with A = 0.7. Without dither, q0 = round(x). With triangular dither, q1 = round(x + d) with d = u1 + u2 - 1 and u1, u2 from numpy.random.default_rng(seed).random((2, 1024)). Using an FFT, set h3_0 and h3_1: the magnitudes of bin 21 (the third harmonic) divided by bin 7 for each, and fund_1, bin 7's magnitude for the dithered version divided by bin 7 of x itself.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Explain why
A digital audio recording fades out slowly at the end of a song. Without dither, the last seconds sound harsh and buzzy before cutting to silence; with dither, they fade smoothly into a faint hiss. Explain both.
As the music fades, its amplitude falls toward a few quantization steps. Without dither, the rounding error is a fixed function of the waveform, so for a quiet, nearly periodic signal it repeats with the signal and becomes harmonic distortion, which sounds harsh and buzzy, and once the signal falls below half a step around zero it rounds to zero and stops abruptly. With dither, a small random noise is added before rounding, so the error becomes independent of the music: the distortion turns into a steady, low noise floor, and even signals smaller than one step still affect the rounding probabilities, so they remain audible inside the hiss and fade smoothly. Our ears tolerate a little steady noise much better than distortion that follows the music.
Practice
Keep practicing
8 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.