Skip to content
AI360XpertBeta

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.

The rate curve falls from lossless entropy to zero, passing 1 bit at distortion 1 for a variance-4 Gaussian
The rate curve falls from lossless entropy to zero, passing 1 bit at distortion 1 for a variance-4 Gaussian

Why Does This Exist?

Lossless compression has one number in entropy HH. 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 R(D)=min⁡p(x^∣x): E[d]≤DI(X;X^)R(D) = \min_{p(\hat{x}\mid x):\,\mathbb{E}[d] \leq D} I(X;\hat{X}) prices each distortion level in bits. The Gaussian squared error case gives the closed form R(D)=12log⁡2(σ2/D)R(D) = \frac{1}{2}\log_2(\sigma^2/D). 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 d(x,x^)d(x, \hat{x}) sets the currency: squared error, Hamming, perceptual. Rate RR is bits per symbol. R(D)R(D) falls convexly from HH at D=0D = 0 to 00 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 HH bits reproduces every pore. A sketch artist charging R(D)R(D) bits captures likeness within agreed sloppiness DD. A caricaturist charging 00 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 R(D)R(D) needs a fixed dd. Wrong distortion, right curve, unhappy viewers.

How It Actually Works

Blahut Arimoto computes R(D)R(D) by alternating minimization. Shannon supplies both halves: the converse says below the curve is impossible, achievability says random codebooks hit it. The Gaussian N(0,σ2)N(0,\sigma^2) with squared error gives R(D)=max⁡(0,12log⁡2(σ2/D))R(D) = \max(0, \frac{1}{2}\log_2(\sigma^2/D)). The binary symmetric source with Hamming distortion gives R(D)=1−Hb(D)R(D) = 1 - H_b(D) for D≤0.5D \leq 0.5. In practice JPEG quantizes DCT bands along the curve slope with equal marginal dR/dDdR/dD per band. Vector quantization and neural codecs learn the frontier.

Worked example

Take a Gaussian with σ2=4\sigma^2 = 4 and target D=1D = 1: R(1)=12log⁡2(4/1)=12(2)=1R(1) = \frac{1}{2}\log_2(4/1) = \frac{1}{2}(2) = 1 bit per symbol. At D=4D = 4: R=0R = 0 because guessing the mean already meets the tolerance. At D=0.25D = 0.25: 12log⁡2(16)=2\frac{1}{2}\log_2(16) = 2 bits. Halving distortion past 11 costs a full extra bit per symbol. That slope is the codec price list. Scalar Lloyd Max quantizers sit about 0.250.25 bits above R(D)R(D) at high rate, the 1.531.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.0

Distortions 44, 11, and 0.250.25 price at 00, 11, and 22 bits: exactly the log formula.

Watch Out For

Optimizing MSE rate for perceptual quality

MSE based R(D)R(D) 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 dd 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

R(D)R(D) 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

  • R(D)R(D) prices each distortion in bits. Below curve operation is impossible.
  • Gaussian variance 44 needs 00 bits at D=4D = 4, 11 bit at D=1D = 1, 22 bits at D=0.25D = 0.25.
  • Halving distortion costs about 11 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.