A fair coin is flipped a million times and you have to store the result. Compression cannot help. The entropy of a fair coin is bit per flip, so a million bits is the least that will do.

Now change the rules a little. You are allowed to get some of the flips wrong. If 11% of the stored flips may be wrong, how many bits do you need?

The answer is half a million: half a bit per flip. Tolerating one error in nine cuts the storage in half. And if half of the flips may be wrong, you need no bits at all, because you can simply guess.

The curve R = 1 - H(D) for fair coin flips. It falls from 1 bit at no errors, through half a bit at 11% errors, to 0 bits at 50% errors. Points above the curve are possible, points below are impossible. A purple dot above the curve marks the majority-of-three code: one third of a bit per flip with 25% of the flips wrong.

This curve is what the note is about. The number of bits per symbol is called the rate . The amount of error we tolerate is called the distortion . The rate distortion function is the smallest rate that keeps the distortion at or below . Every point above the curve can be reached by some code. No code can reach a point below it.

The main result is a formula for the curve:

where is one source symbol and is the symbol the decoder puts in its place. Section 1 explains what is being minimized. Sections 2 to 4 calculate the minimum for the sources that appear in the problems.

This note follows Chapter 10 of Cover & Thomas, Elements of Information Theory (second edition), referred to below as “the book”. It covers only the parts that Problem Set 6 and the practice Midterm 2 use: calculating for a given source and distortion measure, the two ends of the curve, the Gaussian source, the converse, and sending a source over a noisy channel. It leaves out strongly typical sequences, the general equations for the minimizing distribution, and the Blahut–Arimoto algorithm (book Sections 10.6 to 10.8). The proof that the curve can be reached is given only as an idea.

How to read this note

Every section starts from an example with numbers and then states the general rule. Short calculations are shown in the text, because the same few steps solve every problem here. The two longer proofs, in Section 5, are in collapsed boxes. Homework and exam problems sit in the section they belong to, with the full statement in a box and the solution in a collapsed box below it. Try each problem before opening its solution.

What we use from earlier notes

Every term below is used later. Each has a one-line reminder here.

  • Entropy and conditional entropy : the uncertainty in , and what is left of it once is known. Conditioning never increases entropy: . A variable with possible values has entropy at most . See entropy and mutual information.
  • Binary entropy : the entropy of a coin with bias . It increases from at to bit at . The problem sheets write this function as . This note writes and keeps the small for differential entropy.
  • Mutual information : the number of bits that tells us about .
  • Data-processing inequality. If is a Markov chain, then . Processing cannot create information. See data processing.
  • Fano’s inequality. If takes values and , then . See Fano’s inequality.
  • Convex function and Jensen’s inequality. A function is convex if its graph lies below its chords. For a convex , the average of is at least of the average. See Jensen’s inequality.
  • Channel capacity : the largest rate at which a channel can carry bits reliably. See channel capacity.
  • Differential entropy : entropy for a continuous variable. Among all variables with , the Gaussian has the largest: . See differential entropy.

1. The Problem

1.1 A small lossy code

Here is the smallest code that shows every part of the problem. Take the fair coin flips three at a time, and store each group of three in one bit: the majority.

Source flipsStored bitDecoder outputsFlips wrong
00000000 of 3
001, 010, 10000001 of 3
011, 101, 11011111 of 3
11111110 of 3

Three flips cost one bit, so the rate is bit per flip. The eight groups are equally likely. Six of them come back with one flip in three wrong and two come back exact, so the average fraction of wrong flips is

This code is the purple dot in the figure above, at . It is above the curve, so it is possible, but it is not the best. At a rate of the curve allows . Closing the gap takes codes that work on many more than three flips at a time.

The parts of this code have names, and every code in this note has the same parts.

  • The list of sequences that the decoder can output, here , is the codebook. Its members are codewords.
  • The encoder looks at the source sequence, finds the closest codeword, and sends its position in the list. That position is the index.
  • The decoder outputs the codeword with that index. This output is the reconstruction.

1.2 Encoder and decoder in general

A source produces symbols , independent and all with the same distribution . We write the whole sequence as .

A code of rate has a codebook of codewords, each symbols long. The index is then a number between and . Writing it down takes bits, which is bits per source symbol. The reconstruction is written . In the small code, and .

A source sequence enters the encoder, which sends an index of nR bits. The decoder looks the index up in its codebook and outputs the reconstruction.

To say which codeword is “closest”, we need a way to measure how far a reconstruction is from the source.

1.3 Distortion

A distortion measure is a function . It is the cost of representing the source symbol by the reconstruction symbol . Two measures are used far more than any other.

  • Hamming distortion: if and otherwise. The average distortion is then the probability of error, . This is what “fraction of flips wrong” measured in the small code.
  • Squared-error distortion: , for real-valued sources.

For finite alphabets the measure is often given as a matrix, with one row for each and one column for each . Hamming distortion for a coin is

The distortion between two sequences is the average over their symbols,

and the distortion of a code is the expected value when the source sequence is random. For the small code it is .

1.4 The rate distortion function

A pair is achievable if there are codes with rate , for longer and longer blocks, whose distortion is at most in the limit.

Definition. The rate distortion function is the smallest rate such that is achievable.

This definition is about codes. It says what means, but it gives no way to compute it, since we cannot search over all codes of all lengths.

1.5 The rate distortion theorem

Theorem (rate distortion theorem). For an i.i.d. source and a bounded distortion measure ,

The minimum is over all conditional distributions for which the pair , with joint distribution , has expected distortion at most .

What is. It is a table with one row for each source symbol. Row says: of all the source symbols equal to , what fraction is reconstructed as each ? Every code has such a table. In the majority code a flip comes back wrong one time in four, whatever its value, so the table is

Two numbers can be read off a table, once the source distribution is known:

  • its distortion , here ,
  • its mutual information , here bits.

What it means. The mutual information of a table is its price in bits per symbol. No code can have a rate below the mutual information of its own table (Section 5 proves this), and good codes on long blocks have a rate barely above it. The majority code pays bits for a table that is worth . That waste is the cost of working on three flips at a time.

So the search for the best code turns into a search for the cheapest table: among all tables with distortion at most , find the one with the smallest mutual information. That smallest value is . The right-hand side of the theorem contains no codes and no block length. It is a calculation about a single source symbol and a single reconstruction symbol .

It also makes sense that less mutual information means fewer bits. A table is a noisy way of copying . The more noise, the less says about , and the less there is to store. The distortion limit is what stops us from adding too much noise.

Reading the formula once. Take the fair coin and . One allowed table is “copy the flip, but get it wrong with probability “. Its distortion is , and its mutual information is

A minimum cannot be larger than the value at one particular table, so . To show that it equals we still have to show that no other table with at most 11% errors is cheaper. That is the work of Section 2.

The parallel with channel capacity is close.

Channel capacityRate distortion
What is giventhe channel the source and the measure
What we choosethe input distribution the table
What we compute
What it isthe most bits a channel can carrythe fewest bits a source needs

Why it is believable. Count, for fair coin flips. There are source sequences of length , all equally likely, and each one needs a codeword that differs from it in at most places. One codeword can serve only the sequences that are that close to it, and there are about of those. So the codebook needs at least

codewords, which is a rate of . The surprising half of the theorem is that about this many are also enough. When is large, a codebook of that size filled at random leaves almost no source sequence without a codeword nearby. The proof uses jointly typical sequences and is not given here. The other half, that no code does better than the formula, is proved in Section 5.


2. Calculating : the Two-Step Method

2.1 The method

We cannot try every table. Almost every problem is solved by two steps that avoid the search.

The two-step method

Step 1: a floor. Show that every allowed table has at least some number. Start from . The first term is fixed by the source, so the work is to show that cannot be large when the distortion is small.

Step 2: one table that reaches the floor. Write down one allowed pair whose mutual information equals that number.

Step 1 gives floor. Step 2 gives floor. So is the floor.

Step 1 is a chain of inequalities. Each inequality becomes an equality only under some condition, and those conditions say what the pair in Step 2 must look like. So Step 2 is never a guess.

2.2 Binary source with Hamming distortion

Let be a coin with , and let the distortion be the probability of error.

Theorem. The rate distortion function of a Bernoulli() source with Hamming distortion is

Assume (otherwise swap the names of the two symbols) and take .

Step 1: the floor. Let be the error indicator: it is when and otherwise. For any table with ,

  • Line 2. Once is known, knowing is the same as knowing whether an error occurred.
  • Line 3. Dropping the conditioning can only increase an entropy.
  • Line 4. is a coin that shows with the error probability. That probability is at most , and is increasing on that range, so the entropy is at most .

In words: once is known, all that is left to learn about is where the errors are, and an error pattern with at most a fraction of errors has entropy at most .

Step 2: a pair that reaches it. Line 3 is an equality when the error indicator is independent of . Line 4 is an equality when the error probability is exactly . Both conditions describe given , so build the pair in that direction: choose first, then produce by flipping with probability .

The test channel for a binary source. Reconstruction symbols on the left, source symbols on the right. Straight arrows have probability 1 - D and crossing arrows have probability D.

This backward description, , is called the test channel. Nothing is sent through it. It is only a convenient way to write down the joint distribution of .

One thing is left to choose: . The that comes out of the test channel must have the source distribution, :

For a fair coin this gives . In general is a valid probability exactly when . For this pair and the error probability is , so . The floor is reached.

When . Let always. This is wrong exactly when , so the distortion is , and it costs no bits because the decoder already knows what to output. Hence .

What it means. At the rate is , the lossless rate. Allowing errors lowers the rate by , which is the entropy of the error pattern: these are the bits we no longer have to send. The curve reaches zero at , the error rate of the trivial reconstruction “always output the more likely symbol”.

Three rate distortion curves for coins with bias 0.5, 0.2 and 0.1. Each starts at H(p) and reaches zero at D = p.

For example, for a coin with and ,

2.3 Step 1 by counting

Step 1 has a version that works for any distortion matrix of zeros and ones, and it is the one to use in exam problems. It rests on one question:

Given the reconstruction , and given whether a cost was paid, how many values of are still possible?

Call the answers and :

  • is the number of source symbols at distortion from a given (the zeros in its column of the matrix),
  • is the number of source symbols at distortion from it (the ones in its column).

For the coin, and : knowing and whether there was an error leaves exactly one .

Now let be the cost that actually occurs, or , and let , which is the expected distortion. Then

  • Line 1. is computed from and , so writing it next to adds nothing.
  • Line 2. The chain rule.
  • Line 3. Drop the conditioning in the first term, and split the second term by the value of .
  • Line 4. is a coin with bias . Given and , the source is one of symbols, so its entropy is at most . The same holds for with .

The result is worth remembering as it stands:

It says that what leaves unknown about has two parts: whether a cost was paid, and which of the remaining candidates is. Here is what it gives for the three matrices in this note.

Source and distortionBound on
Coin, Hamming (Section 2.2)
symbols, Hamming (the next problem), which is Fano’s inequality
Three symbols with ties (practice midterm, Section 3)

The first three lines of the chain are the hint printed in the practice midterm problem. Two more things finish a calculation.

From to . We only know , and we want the bound with in it. That is allowed when the right-hand side is increasing in . Its derivative is , which is nonnegative exactly when . In the three rows above this limit is , and .

Reaching the floor. Line 3 is an equality when is independent of . Line 4 is an equality when is equally likely to be any of its candidates. So the test channel gives probability to each zero-cost and to each cost-one . Then check that comes out with the source distribution.

HW6 Problem 2: Rate distortion for uniform source with Hamming distortion (book Problem 10.5)

Let be uniformly distributed on . Find the rate distortion function of under Hamming distortion,


3. The Two Ends of the Curve

Before computing a whole curve it helps to know where it starts and where it ends. Both ends can be found without the two-step method, and exam problems often ask for them separately.

3.1 The right end:

Suppose the decoder gets no bits at all. It must output a reconstruction that does not depend on the source, and the best it can do is to output, every time, the single symbol with the smallest average cost. That cost is

Then for every , and for every .

To find from a distortion matrix: weight each row by , add up each column, and take the smallest column sum. For example, take a coin with and Hamming distortion. The rows have weights and .

So : always output , and be wrong on the 20% of symbols that are . In general a coin has , and the uniform source on symbols has , since every column sum is the same.

The reason no other zero-rate scheme does better is short. exactly when is independent of . For an independent the expected distortion is an average of the column sums, and an average cannot be smaller than the smallest of them.

3.2 The left end:

At every symbol must be reconstructed at zero cost.

If the only zero-cost reconstruction of is itself, as with Hamming distortion, then and

This is lossless compression. The source coding theorem of the earlier notes is the point of this theory.

With ties, can be smaller than . A row of the distortion matrix with more than one is a tie: that source symbol has several reconstructions that cost nothing. Then does not have to identify , and fewer bits are needed.

For example, let be uniform on and let the reconstruction be one of two labels: “low”, which costs nothing when , and “high”, which costs nothing when . Zero distortion only requires us to say which half is in. That takes bit, while bits.

The count of Section 2.3 gives the general rule. At only zero-cost pairs may occur, so given the source is one of symbols. Hence and

with equality when some allowed pair makes equally likely to be any of the candidates. In the example, and bit.

A distortion measure with ties. Each of the three source symbols is joined to two reconstruction symbols at distortion 0 and to one at distortion 1.

The figure shows the distortion measure of the practice midterm problem at the end of this section. Each reconstruction symbol is free for two source symbols, so and .

3.3 Infinite distortion: forbidden pairs

An entry equal to marks a forbidden pair: that must never be reconstructed as that . The reason is that any table that gives the pair positive probability has infinite expected distortion. So for every finite ,

This removes most of the freedom in the table. Often only one or two free numbers remain, and then can be written as a function of them and minimized directly. The next two problems are of this kind.

The rate distortion theorem was stated for bounded distortion measures. The two problems ask for the formula itself, which is well defined with infinite entries.

HW6 Problem 1: Rate distortion function with infinite distortion (book Problem 10.2)

Let , and consider the distortion measure

Find the rate distortion function .

HW6 Problem 3: Erasure distortion (book Problem 10.7)

Let , let the reconstruction alphabet be , where denotes an erasure, and let the distortion matrix be

with rows indexed by and columns by . Find the rate distortion function of this source. Can you suggest a simple scheme that achieves any value of the rate distortion function?

The last problem of this section is from the practice midterm. It uses everything so far: a tie at zero distortion, Step 1 by counting, a test channel, and .

Practice Midterm 2, Problem 4: Rate distortion (15 points)

Consider a ternary source coding problem with . Suppose the source is uniformly distributed, and the distortion measure is given by

Alternatively, we can describe the distortion measure by the matrix

Note: for each source symbol there are two reproduction symbols that result in zero distortion.

(a) Find for . (Be careful, this is not the same as lossless source coding.)

(b) For , show that

Hint: you may want to use the following as a starting point,

and then show that

where .

(c) Find a joint distribution on that achieves the lower bound in part (b), thus establishing that the lower bound in (b) equals for .

(d) Show that for .


4. The Gaussian Source

4.1 The rate distortion function

Now the source is a real number, , and the cost is the squared error . The theorem of Section 1.5 still holds, with differential entropies in place of entropies, and the same two steps work.

Theorem. The rate distortion function of a source with squared-error distortion is

Step 1: the floor. For any pair with ,

  • Line 2. The first term is the entropy of a Gaussian. In the second, is known, so subtracting it is only a shift, and a shift does not change differential entropy.
  • Line 3. Dropping the conditioning can only increase an entropy.
  • Line 4. The error has mean square at most , and no variable with that mean square has more entropy than a Gaussian of variance .

These are the same moves as for the coin. There the error was and its entropy was at most . Here the error is and its entropy is at most .

Step 2: a pair that reaches it. Line 3 is an equality when the error is independent of . Line 4 is an equality when the error is Gaussian with variance exactly . So build the pair from again: the test channel adds independent Gaussian noise to the reconstruction.

The test channel for a Gaussian source: the reconstruction, with variance sigma squared minus D, plus independent noise Z with variance D, gives the source with variance sigma squared.

The variance of is chosen so that has variance , as the source requires. This is possible when .

When . Output always. The squared error is , at no cost. So .

What it means. Turn the formula around to get the smallest distortion at a given rate:

Each extra bit per sample divides the squared error by four. With bit per sample the best possible distortion is .

Compare this with the obvious way to spend one bit on one sample: send the sign of , and reconstruct a positive sample as and a negative one as (the averages of the two halves of the bell curve). This is the best that can be done with one sample at a time, and its distortion is . The curve promises at the same rate. As with the majority code of Section 1.1, the gap is closed only by describing many samples together with one index, even though the samples are independent.

The rate distortion curve of a Gaussian source. It passes through 2 bits at D equal to sigma squared over 16 and 1 bit at sigma squared over 4, and reaches 0 at sigma squared. The best one-sample quantizer at 1 bit has distortion 0.36 sigma squared, to the right of the curve.

The next problem repeats the two steps for a source that is not Gaussian. They no longer meet, but they trap between two bounds.

HW6 Problem 4: Bounds on rate distortion function for squared-error distortion (book Problem 10.8)

Let be a continuous random variable with mean and variance , and use squared-error distortion. Show that

For the upper bound, consider the test channel

where is independent of . Using these bounds, decide whether a Gaussian random variable is harder or easier to describe than a non-Gaussian one with the same variance.

(The problem sheet writes for the differential entropy. It is written here.)

4.2 Several independent Gaussians: reverse water-filling

Suppose we must describe independent Gaussian components with different variances , and the limit is on the total squared error . How should the distortion be shared among the components?

Start with two components, with variances and .

  • Total distortion . Give each component the same distortion, . The rate is bits.
  • Total distortion . An equal share would be each, but the second component has variance only . Outputting for it already has distortion and costs nothing. So drop it, with , which leaves . The rate is bits, all spent on the first component.

The general rule is the same: an equal level for every component, except that no component is given more distortion than its own variance.

Theorem (reverse water-filling).

where the level is chosen so that .

Reverse water-filling. Six bars show the variances of six components. A horizontal level lambda cuts across. Components taller than lambda keep distortion lambda. Components shorter than lambda get zero bits.

What it means. Every component is described down to the same distortion . A component whose variance is already below is not described at all: the decoder outputs for it, its distortion is its whole variance, and it receives no bits. All the bits go to the components with large variance.

The reason for the equal level is that the rate of component is , so allowing it a little more distortion saves bits in proportion to . If two components had different , moving some distortion from the larger to the smaller would lower the total rate. The exception is a component that has reached . Its rate is already zero and cannot be lowered further.

The name comes from the channel version of the same picture. There, power is poured on top of the noise levels up to a common water level. Here the level is drawn from above, and what lies under it is thrown away.


5. The Converse: No Code Can Beat

Sections 2 to 4 calculated the formula . This section shows that no code can do better than the formula. From here on, stands for the formula.

5.1 The curve is nonincreasing and convex

Lemma. is a nonincreasing, convex function of .

What it means. The curve falls, and it falls most steeply at the start: the first units of distortion we tolerate save the most bits. Every curve in this note has this shape. The straight line of the erasure problem is the borderline case.

It is nonincreasing because a larger allows more tables, and a minimum over a larger set cannot be larger. Convexity takes one more idea, which is to mix two tables.

5.2 The converse

Theorem (converse). Let be an i.i.d. source and let be any sequence with , however it was produced. Then

What it means. To be within distortion of the source, a reconstruction must contain at least bits of information about it. The statement does not mention an encoder or an index, so it applies to every way of producing . The next section uses it when the reconstruction is made from the output of a noisy channel.

Why this limits every code. Take a code with rate and distortion at most , and let be the index it sends. Then

The index takes at most values, so its entropy is at most . Mutual information with cannot exceed the entropy of . The reconstruction is computed from alone, so by the data-processing inequality it cannot know more about than does. The last step is the theorem. So : the index is the only way information reaches the decoder, and it must carry at least bits.


6. Sending a Source over a Noisy Channel

The source-channel separation theorem said that a source can be sent over a channel with vanishing error exactly when its entropy is below the capacity. If the entropy is above the capacity, perfect reconstruction is impossible. But we may be content with a reconstruction that is only close. How close can it be?

Start with an example. Fair coin flips are sent over a binary symmetric channel with flip probability , one channel use per flip. The capacity is bits per use, less than the bit per flip that the source produces, so some flips must arrive wrong. The fewest errors come from the at which the source needs exactly what the channel delivers:

No scheme can deliver the flips with fewer than 11% errors. For this source and channel, sending the flips uncoded already achieves it.

A source sequence is encoded, sent through a channel of capacity C, and decoded into a reconstruction. Distortion D can be reached when C is greater than R(D) and cannot when C is less than R(D).

Theorem (source-channel separation with distortion). Let be an i.i.d. source with a finite alphabet, sent with one channel use per source symbol over a discrete memoryless channel with capacity , and reconstructed as . Distortion can be achieved if , and cannot be achieved if .

What it means. is the number of bits per symbol that the source needs for distortion . is the number of bits per use that the channel delivers. The reconstruction can have distortion exactly when the channel delivers more than the source needs. To find the best distortion for a given source and channel, solve , as in the example.

The two-stage design is again enough: first compress the source to about bits per symbol with a rate distortion code, ignoring the channel, then protect those bits with a channel code, ignoring where they came from. No design that mixes the two stages can reach a smaller distortion.

The proof is the next problem.

HW6 Problem 5: Source-channel separation theorem with distortion (book Problem 10.17)

Let be an i.i.d. source with a finite alphabet. The source sequence is encoded into inputs of a discrete memoryless channel with capacity , and the channel output is mapped to a reconstruction . Let

be the average distortion of this combined source and channel coding scheme, and let be the rate distortion function of .

(a) Show that if , there exist encoders and decoders whose average distortion is arbitrarily close to .

(b) (Converse) Show that if the average distortion equals , then the capacity must be greater than .


Summary

The problem. A rate distortion code describes source symbols with bits. is the smallest rate at which the average distortion can be kept at or below .

The theorem.

Here is a table saying how often each source symbol is reconstructed as each . Its mutual information is its price in bits per symbol, and is the price of the cheapest table with distortion at most .

How to calculate it.

  1. Read the distortion matrix. Entries equal to force . Rows with several zeros are ties. For each column count , the number of zeros, and , the number of ones.
  2. Find the right end: , and for .
  3. Step 1, the floor: write and use . Check that the bound is increasing in before replacing by .
  4. Step 2, a pair that reaches it: choose and a test channel that give its distribution, have distortion , and make every inequality an equality. This usually means: the error is independent of , and is uniform over its candidates.
  5. Check the ends: the formula should give at and at .

Closed forms.

Source and distortionRange of
Bernoulli(), Hamming
Uniform on symbols, Hamming
Fair coin, erasure distortion
Gaussian , squared error
Any source with variance , squared errorbetween and
Independent Gaussians, total squared error with

Beyond the stated range, .

Facts to remember.

  • is nonincreasing and convex.
  • when only has zero distortion. With ties, is smaller.
  • Among sources with the same variance, the Gaussian is the hardest to describe.
  • Any reconstruction within distortion of an i.i.d. source satisfies .
  • A source can be sent over a channel with distortion if , and cannot if .