C922 of 55
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

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 2N 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 2N 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?

Name it

The quantizer

An N-bit converter spanning a range R has step Δ=R/2N and rounds each sample to the nearest level. The error lies between −Δ/2 and Δ/2.

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

σq2=Δ212

spread evenly from 0 to fs/2. A full-scale sine has power R2/8, so its signal-to-quantization-noise ratio is

SQNR=6.02N+1.76 dB

A real converter adds its own noise and distortion; its measured SINAD defines an effective number of bits, ENOB=(SINAD−1.76)/6.02.

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 Δ/2 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 fs/2. Sampling M times faster than the signal needs and filtering away everything above the signal band keeps only 1/M of the noise: 10log10⁡M 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
  1. Step. Δ=3.3/4096V=0.806mV
  2. RMS noise. Δ/12=0.233mV
  3. Ideal SQNR. SQNR=6.02×12+1.76=74.0dB
  4. Compare a real part. If the datasheet quotes a SINAD of 62 dB, the ENOB is ENOB=(62−1.76)/6.02=10.0bits 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
  1. 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.
  2. With dither. Each sample's rounding depends on the signal plus a random offset, and the average of many readings follows the signal.
  3. Noise per sample. The dither's 2Δ/12=Δ/3 rms and the rounding's Δ/12 together make σ=Δ1/3+1/12=Δ5/12=0.65Δ
  4. Average 1000 samples. Averaging reduces that by 1000: 0.65Δ/1000≈0.02Δ 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
  1. Oversampling ratio. 640/40=16
  2. Noise reduction. The in-band noise falls by two bits' worth: 10log10⁡16=12.0dB
  3. New SQNR. 62.0+12.0=74.0dB as good as an ideal 12-bit converter at the plain rate.
  4. 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.

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.