Quantisation Noise, Dither and Word Length
Sampling discretises time; quantisation discretises amplitude. Every ADC rounds each sample to one of codes, and every fixed-point DSP operation rounds again. The famous rule " per bit" hides three engineering questions: how much signal-to-quantisation-noise ratio do you really get when the signal is not a full-scale sine, what happens to very small signals that span only a few codes, and how many bits must the arithmetic inside a filter carry. The derivation of the uniform noise model is in Quantization; the converter-testing side (SINAD, ENOB, coherent sampling) is in Data Acquisition. This lesson is about designing with quantisation.
The additive noise model
A uniform quantiser with step (one LSB) maps to . Write the result as the input plus an error, . When the signal is "busy" (it crosses many codes in an irregular way) the error behaves like white noise, uniform on :
For a bipolar converter with full scale , , and the signal-to-quantisation-noise ratio of a signal with rms value is
For a full-scale sine and the formula becomes the familiar . Two corrections matter in practice:
- Level. Every dB the signal sits below full scale is a dB of SQNR lost. A sine at on a 16-bit converter gets , not .
- Crest factor. Noise-like signals (speech, vibration, a multi-carrier radio signal) need headroom so their peaks do not clip; with peaks at the formula gives , about less than a full-scale sine.
Rounding vs truncation. Truncating (dropping the low bits, rounding toward ) has the same noise power but a mean error of , a DC offset that accumulates in integrators and long filters. Round, or account for the offset.
Worked example: two converters, two signals
Given: (a) a 16-bit audio ADC recording a quiet passage, a sine at ; (b) a 12-bit microcontroller ADC, to , digitising vibration noise centred at mid-scale with .
Find: the SQNR in each case.
Solve: (a) . (b) , rms, .
Check: with the formula for (b), unipolar range is a bipolar : . The 12-bit converter used at a to crest margin performs like a full-scale 8.5-bit one: the cost of headroom.
import numpy as np
rng = np.random.default_rng(1)
def sqnr_db(x, q):
e = q * np.round(x / q) - x
return 10 * np.log10(np.mean(x**2) / np.mean(e**2))
N, n = 16, 2**16
q = 2.0 / 2**N # +/-1 V full scale
t = np.arange(n)
for level in (0, -20, -40, -60):
A = 10 ** (level / 20) * (1 - 1e-9)
x = A * np.sin(2 * np.pi * 0.0123457 * t + 0.3) # an "irrational" frequency exercises many codes
print(f"16-bit, sine at {level:4d} dBFS: SQNR {sqnr_db(x, q):6.2f} dB (formula {98.09 + level:6.2f})")
qa = 3.3 / 4096 # 12-bit, 0..3.3 V
x = 0.1 * rng.standard_normal(n) # vibration noise around mid-scale, sigma 0.1 V
print(f"12-bit, noise sigma 0.1 V: SQNR {sqnr_db(x, qa):.2f} dB")
trunc = qa * np.floor(x / qa) - x
print(f"truncation: mean error {1e3 * trunc.mean():.4f} mV (-q/2 = {-1e3 * qa / 2:.4f} mV), rms {1e3 * trunc.std():.4f} mV")16-bit, sine at 0 dBFS: SQNR 98.09 dB (formula 98.09)
16-bit, sine at -20 dBFS: SQNR 78.03 dB (formula 78.09)
16-bit, sine at -40 dBFS: SQNR 58.09 dB (formula 58.09)
16-bit, sine at -60 dBFS: SQNR 38.29 dB (formula 38.09)
12-bit, noise sigma 0.1 V: SQNR 52.66 dB
truncation: mean error -0.4034 mV (-q/2 = -0.4028 mV), rms 0.2332 mV
Small signals and dither
The white-noise model fails when the signal is small or very regular. A sine of LSB amplitude crosses only three codes; the error is then a deterministic function of the signal, which shows up as harmonics (distortion) instead of noise. Even worse, a slowly varying input smaller than half an LSB disappears entirely. The cure is dither: add a small random signal before the quantiser. Triangular-PDF (TPDF) dither of LSB peak makes the error's mean and variance independent of the signal: the harmonics vanish, the total error power rises from to (a penalty), and averaging can recover detail below one LSB.
import numpy as np
import matplotlib.pyplot as plt
rng = np.random.default_rng(7)
n, k0 = 8192, 31 # coherent tone: 31 cycles in 8192 samples
t = np.arange(n)
x = 1.3 * np.sin(2 * np.pi * k0 * t / n) # 1.3 LSB amplitude, q = 1
tpdf = rng.uniform(-0.5, 0.5, n) + rng.uniform(-0.5, 0.5, n) # triangular, +/-1 LSB peak
spectra = {}
for name, d in (("no dither", 0.0), ("TPDF dither", tpdf)):
y = np.round(x + d)
e = y - x
Y = np.abs(np.fft.rfft(y)) / n * 2
harm = [20 * np.log10(Y[h * k0] / Y[k0] + 1e-15) for h in (3, 5, 7)]
print(f"{name:12s}: error rms {e.std():.3f} LSB, H3 {harm[0]:6.1f} dBc, H5 {harm[1]:6.1f} dBc, H7 {harm[2]:6.1f} dBc")
spectra[name] = 20 * np.log10(Y / Y[k0] + 1e-12)
print(f"theory: rms without dither (busy signal) {1 / np.sqrt(12):.3f} LSB, with TPDF {0.5:.3f} LSB")
f = np.arange(n // 2 + 1) / n
plt.figure(figsize=(7, 3))
for name, s in spectra.items():
plt.plot(f, s, lw=0.8, label=name)
plt.xlim(0, 0.1); plt.ylim(-90, 5); plt.xlabel("f / fs"); plt.ylabel("dBc")
plt.legend(); plt.tight_layout(); plt.show()no dither : error rms 0.256 LSB, H3 -17.3 dBc, H5 -21.4 dBc, H7 -16.8 dBc
TPDF dither : error rms 0.501 LSB, H3 -40.6 dBc, H5 -45.0 dBc, H7 -45.2 dBc
theory: rms without dither (busy signal) 0.289 LSB, with TPDF 0.500 LSB
Without dither the odd harmonics are only to below the tone: a pure tone has turned into a distorted one, and the error ( LSB rms) does not even follow the busy-signal value of LSB. With dither the harmonic bins fall to to , which is just the flat noise floor in those bins, and the error is the predicted LSB rms. Audio mastering adds dither every time it reduces word length (24 to 16 bits); measurement systems often get "free" dither from the analog noise of the front end, which is why averaging improves a noisy ADC's resolution but not a perfectly quiet one's.
Noise shaping goes one step further: feed the quantisation error back so it is pushed out of the band of interest, for first order. The total noise grows but the in-band part shrinks; combined with oversampling this is the principle of sigma-delta converters.
Word length inside the DSP
The same model covers arithmetic. Each rounding after a multiply injects about of noise at that point, which the rest of the filter then shapes and amplifies; a narrow-band IIR filter can amplify it by tens of dB. Typical rules of thumb, worked out in Filter Structures and Fixed Point:
- Data path: at least as many bits as the converter, plus margin for the filter's noise gain.
- Coefficients: enough bits that the quantised poles and zeros stay where you designed them (Biquads).
- Accumulators: wide (a 16 × 16-bit multiply gives 32 bits; many 16-bit DSPs accumulate in 40 bits) and rounded once at the end.
Guided lab: the code histogram of a quiet ADC
Hand calculation. A 12-bit, ADC has . If the input noise is much below , every reading of a steady DC input is the same code (or two neighbours), and averaging 16 readings cannot do better than one LSB. If the front-end noise is about LSB rms or more, the codes spread and averaging 16 readings improves the resolution about fourfold.
Simulation. In the dither program set the amplitude to (below half an LSB) and print np.unique(y) without dither: the tone vanishes entirely (all zeros). With dither, averaging many periods recovers it.
What you would measure. Apply a steady from a divider on the board's reference (with a capacitor at the ADC pin) and log 1000 readings. A quiet layout gives a histogram 1 to 3 codes wide; with the processor's radio or USB busy, typically 5 to 10 codes. The standard deviation in LSB is the input-referred noise; compare its mean with the expected code , within the ADC's offset and gain error (often several LSB).
Hazards and safe setup. USB-powered board; the divider runs from the board's own , so the input can never exceed the pin's range.
Pitfalls
- Quoting for signals that use a fraction of full scale.
- Truncating instead of rounding and finding a DC offset downstream.
- Expecting averaging to add resolution to a noiseless converter.
- Reducing word length (24 to 16 bits) without dither and getting distortion on quiet passages.
Practice
- What SQNR does a 24-bit converter have for a sine at ?
- A 10-bit converter quantises a Gaussian signal with peaks at just reaching full scale. What is the SQNR?
- How much does TPDF dither of LSB raise the noise floor?
Answer
- (in reality limited by the analog noise, typically to of dynamic range).
- .
- From to : .
Test yourself
The quantisation noise power of a rounding quantiser with step is
A 16-bit ADC records a sine at dBFS. Its SQNR is about
- 98 dB
- 78 dB
- 58 dB
- 118 dB
Dither before a quantiser
- lowers the total noise
- turns signal-dependent distortion into signal-independent noise
- adds bits to the ADC
- is only for audio
Truncation instead of rounding adds
- more noise power
- a DC offset of
- harmonics only
- nothing