Rate-Distortion Theory
Lossy compression trades bits for error on one curve. The curve prices every fidelity level; JPEG, MP3, and embeddings all live on it.
Why Does This Exist?
Lossless has one number (); lossy has a curve. Shipping thumbnails, voice notes, or cached embeddings tolerates error, and "how many bits for this quality" decides codecs, tiers, and caches. Guessing overpays 2-10x or ships mush.
Rate-distortion prices each distortion level in bits. Gaussian squared-error gives closed form . It extends source and channel coding past zero error and shares math with information bottleneck (relevance replaces fidelity).
The one idea you need first
Distortion (squared error, Hamming, perceptual) sets the currency; rate is bits per symbol. falls convexly from at to past max tolerable error. Operating below the curve is impossible; above is waste.
Think of It Like This
Sketch artists at three prices
A painter ( bits) reproduces every pore. A sketch artist ( bits) captures likeness within agreed sloppiness . A caricaturist (0 bits) draws the average face regardless.
Price rises as sloppiness falls, steeply near perfection. Where it stops: human likeness is perceptual, while needs a fixed . Wrong distortion, right curve, unhappy viewers.
How It Actually Works
Blahut-Arimoto computes by alternating minimization; Shannon's converse (below curve impossible) plus achievability (random codebooks hit it) certify. Gaussian with squared error: . Binary symmetric with Hamming: for . Practice: JPEG quantizes DCT bands along the curve's slope (equal marginal per band); vector quantization and neural codecs learn the frontier.
Worked example
Gaussian , target : bit per symbol. At : (guess the mean). At : bits. Halving distortion past 1 costs a full extra bit per symbol: the curve's slope is the codec's price list. Scalar Lloyd-Max quantizers sit ~0.25 bits above at high rate (the 1.53 dB gap); vector codes close it.
Code
import numpy as np
sigma2 = 4.0for D in [4.0, 1.0, 0.25]: R = max(0.0, 0.5 * np.log2(sigma2 / D)) print(D, round(R, 2)) # -> 0.0, 1.0, 2.0Distortions 4, 1, 0.25 price at 0, 1, 2 bits: exactly the log formula.
Watch Out For
Optimizing MSE rate for perceptual quality
MSE- rankings invert human preference: blurred images win MSE while textures please eyes. Codecs tuned on squared error ship soup that benchmarks love.
Pick matching the use (perceptual, semantic, downstream accuracy). If viewers disagree with the curve, the distortion is wrong, not the theory.
Quoting Shannon rates without finite-block penalty
is asymptotic; short blocks pay backoff (dispersion, header, codebook mismatch). Tiny-packet "near-optimal" claims silently assume infinite messages.
Budget finite-blocklength penalties or measure end-to-end. If packets are short, the curve is a floor with a tall crawlspace.
The Quick Version
- prices each distortion in bits; below-curve operation is impossible.
- Gaussian variance 4: 0 bits at , 1 bit at , 2 bits at .
- Halving distortion costs ~1 extra bit per symbol in the Gaussian regime.
- JPEG and neural codecs ride the curve's equal-slope allocation.
- Match distortion to the use; MSE curves misprice perception.
- Finite blocks pay backoff above the asymptotic floor.