Skip to content
AI360Xpert
Beta

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 has one number (HH); 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 R(D)=minp(hatxmidx):,mathbbE[d]leqDI(X;hatX)R(D) = \\min_{p(\\hat x\\mid x):\\,\\mathbb{E}[d] \\leq D} I(X;\\hat X) prices each distortion level in bits. Gaussian squared-error gives closed form R(D)=tfrac12log2(sigma2/D)R(D) = \\tfrac{1}{2}\\log_2(\\sigma^2/D). 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 d(x,hatx)d(x, \\hat x) (squared error, Hamming, perceptual) sets the currency; rate RR is bits per symbol. R(D)R(D) falls convexly from HH at D=0D = 0 to 00 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 (HH bits) reproduces every pore. A sketch artist (R(D)R(D) bits) captures likeness within agreed sloppiness DD. 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 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's converse (below curve impossible) plus achievability (random codebooks hit it) certify. Gaussian N(0,sigma2)N(0,\\sigma^2) with squared error: R(D)=max(0,tfrac12log2(sigma2/D))R(D) = \\max(0, \\tfrac{1}{2}\\log_2(\\sigma^2/D)). Binary symmetric with Hamming: R(D)=1−Hb(D)R(D) = 1 - H_b(D) for Dleq0.5D \\leq 0.5. Practice: JPEG quantizes DCT bands along the curve's slope (equal marginal dR/dDdR/dD per band); vector quantization and neural codecs learn the frontier.

Worked example

Gaussian sigma2=4\\sigma^2 = 4, target D=1D = 1: R(1)=tfrac12log2(4/1)=tfrac12(2)=1R(1) = \\tfrac{1}{2}\\log_2(4/1) = \\tfrac{1}{2}(2) = 1 bit per symbol. At D=4D = 4: R=0R = 0 (guess the mean). At D=0.25D = 0.25: tfrac12log216=2\\tfrac{1}{2}\\log_2 16 = 2 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 R(D)R(D) 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.0

Distortions 4, 1, 0.25 price at 0, 1, 2 bits: exactly the log formula.

Watch Out For

Optimizing MSE rate for perceptual quality

MSE-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.

Pick dd 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

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

  • R(D)R(D) prices each distortion in bits; below-curve operation is impossible.
  • Gaussian variance 4: 0 bits at D=4D=4, 1 bit at D=1D=1, 2 bits at D=0.25D=0.25.
  • 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.