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 compression has one number in entropy . Lossy compression has a curve. Shipping thumbnails, voice notes, or cached embeddings tolerates error, and how many bits each quality level costs decides codecs, tiers, and caches. Guessing overpays by multiples or ships mush.
Rate distortion prices each distortion level in bits. The Gaussian squared error case gives the closed form . It extends coding past zero error and shares math with information bottleneck, where relevance replaces fidelity, and with minimum description length, which scores whole models instead.
The one idea you need first
Distortion sets the currency: squared error, Hamming, perceptual. Rate is bits per symbol. falls convexly from at to past the maximum tolerable error. Operating below the curve is impossible. Operating above it is waste.
Think of It Like This
Sketch artists at three prices
A painter charging bits reproduces every pore. A sketch artist charging bits captures likeness within agreed sloppiness . A caricaturist charging bits draws the average face regardless of who sits down.
Price rises as sloppiness falls, steeply near perfection. The menu lists every fidelity with its cheapest price.
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 supplies both halves: the converse says below the curve is impossible, achievability says random codebooks hit it. The Gaussian with squared error gives . The binary symmetric source with Hamming distortion gives for . In practice JPEG quantizes DCT bands along the curve slope with equal marginal per band. Vector quantization and neural codecs learn the frontier.
Worked example
Take a Gaussian with and target : bit per symbol. At : because guessing the mean already meets the tolerance. At : bits. Halving distortion past costs a full extra bit per symbol. That slope is the codec price list. Scalar Lloyd Max quantizers sit about bits above at high rate, the 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 , , and price at , , and bits: exactly the log formula.
Watch Out For
Optimizing MSE rate for perceptual quality
MSE based rankings invert human preference. Blurred images win MSE while textures please eyes. Codecs tuned on squared error ship soup that benchmarks love.
Symptom: the curve says better while viewers say worse. Fix: pick matching the use, perceptual, semantic, or 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 from dispersion, headers, and codebook mismatch. Tiny packet near optimal claims silently assume infinite messages.
Symptom: measured rate sits well above the curve at small blocklengths. Fix: 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 needs bits at , bit at , bits at .
- Halving distortion costs about extra bit per symbol in the Gaussian regime.
- JPEG and neural codecs ride the curve with equal slope allocation.
- Match distortion to the use. MSE curves misprice perception.
- Finite blocks pay backoff above the asymptotic floor.