Marginal

Information Theory

Shannon's theory of information: surprisal and entropy, joint and conditional entropy, mutual information, KL divergence and cross-entropy (the loss behind most of machine learning), the data-processing and Pinsker inequalities, maximum entropy, differential entropy, prefix codes and the source coding theorem, Huffman codes, typical sequences, channel capacity, the channel coding theorem and rate–distortion theory.

38 lessons in 3 units

Start your free trial14 days free. No card needed.
What you'll learn

38 lessons, one small step at a time

Each lesson states its goal, then works up to it in short steps with practice after each. A placement test at the start skips what you already know.

Entropy & Information

23 lessons
  1. Information & surprisalCompute the surprisal of an event in bits, and explain why it must be a logarithm.
  2. Bits & natsConvert information between bits and nats, and explain what one bit is.
  3. Binary entropyCompute the entropy of a biased coin and of many tosses, and the redundancy in a record of tosses.
  4. EntropyCompute the entropy of a discrete distribution, and its maximum for a given number of outcomes.
  5. Joint entropyCompute the joint entropy of two variables, and how many bits their dependence saves compared with their separate entropies.
  6. Conditional entropyCompute conditional entropy with the chain rule and as an average over X.
  7. Mutual informationCompute mutual information from a joint distribution, and explain why it detects dependence that correlation misses.
  8. KL divergenceCompute the KL divergence between two distributions, and the divergence of a distribution from the uniform one.
  9. Forward & reverse KLCompute KL divergence in both directions, and explain why forward KL covers mass while reverse KL seeks modes.
  10. Log lossCompute the log loss of one prediction and the average log loss over a dataset.
  11. PerplexityConvert between average log loss and perplexity, and read perplexity as an effective number of choices.
  12. Cross-entropyCompute cross-entropy, and split it into the irreducible entropy and the reducible KL divergence.
  13. The chain rule for informationCompute conditional mutual information, add up information gained in stages, and apply the chain rule for entropy to sequences.
  14. Conditional mutual informationShow how conditioning on a common effect creates dependence, and tell common causes from common effects.
  15. Cascaded noisy channelsCombine the flip probabilities of relays in a row, with a formula and with transition matrices, and compute the information lost.
  16. The data-processing inequalityApply the data-processing inequality to a Markov chain, prove it with the chain rule, and relate it to sufficient statistics.
  17. Fano's inequalityBound the error of guessing X from Y with Fano's inequality, for bits, for many values and in terms of mutual information.
  18. Total variation distanceCompute the total variation distance between two distributions, and the best chance of telling them apart from one sample.
  19. Pinsker's inequalityBound total variation by KL divergence with Pinsker's inequality, bound KL from below by total variation, and judge when the bound is tight.
  20. The maximum entropy principleFind the maximum-entropy distribution for standard states of knowledge, including the exponential with a given mean.
  21. Maximum entropy & GibbsCompute Gibbs probabilities and average energies, derive the Gibbs distribution from maximum entropy, and explain the role of temperature.
  22. Differential entropyCompute the differential entropy of uniform and normal densities, and explain why it depends on units.
  23. KL between normalsCompute the KL divergence between normals with equal and with different variances, derive the equal-variance case, and extend it to many dimensions.

Source Coding

7 lessons
  1. Prefix-free codesTell whether a code is prefix-free, compute its expected codeword length, and decode a bit string without separators.
  2. The Kraft inequalityCompute Kraft sums, decide which sets of codeword lengths are possible, and build a prefix code from given lengths.
  3. Shannon codesCompute Shannon codeword lengths and their expected length.
  4. The source coding theoremState the entropy limit on lossless compression, explain why no code beats it, and compute the cost of coding with the wrong model.
  5. Huffman codingRun Huffman's algorithm, and compute the expected length of the code it builds.
  6. The AEPCompute the per-symbol surprisal of a sequence, and explain what the asymptotic equipartition property says about typical sequences.
  7. Typical setsDefine the typical set, count its sequences, and show they are a vanishing fraction of all sequences.

Channels & Distortion

8 lessons
  1. Information through a channelCompute the output distribution of a binary symmetric channel, and the information that passes through it.
  2. Channel capacityCompute the capacity of the binary symmetric channel and of the erasure channel.
  3. Repetition codesCompute the error probability and the rate of repetition codes.
  4. Hamming codesCompute the block error probability of the Hamming (7,4) code, construct its parity bits, and compare its rate with repetition.
  5. The channel coding theoremApply the channel coding theorem to find the rate a channel can carry reliably, and explain what the theorem means.
  6. The Gaussian channelCompute the capacity of a Gaussian channel per use and per second, explain the formula, and weigh power against bandwidth.
  7. Lossy compression of bitsCompute the rate–distortion function of a binary source, and the distortion achievable at a given rate.
  8. Rate–distortion for GaussiansCompute the bits a Gaussian source needs for a target error and the error at a given rate, and share bits among components by reverse water-filling.
Sample lesson

Information & surprisal

Goal: Compute the surprisal of an event in bits, and explain why it must be a logarithm.

Claude Shannon's 1948 paper "A Mathematical Theory of Communication" founded information theory by asking how to measure information. His answer starts from a single event: the less likely it is, the more you learn when it happens.

We will compute surprisal and finish with why it is a logarithm.

Step 1: Surprisal

Learning that an event of probability p occurred gives

I(p) = −log₂ p = log₂(1/p) bits

A fair coin flip gives 1 bit, an event of probability ¼ gives 2 bits, one of probability 1/16 gives 4, and one of probability 1/1,024 gives 10. A certain event gives none. Learning that a fair die showed an even number gives 1 bit, since that event has probability ½. The base of the logarithm sets the unit: base 2 gives bits.

Step 2: Why the logarithm

Information from independent events should add: learning two unrelated facts should tell you the sum of what each tells you. Independent probabilities multiply, and the logarithm turns products into sums:

I(pq) = I(p) + I(q)

Two independent events of probabilities ½ and 1/32 together give 1 + 5 = 6 bits. The logarithm is the only measure, up to a constant factor (the choice of base, or unit), that is additive over independent events and decreases as probability rises.

In the app, each step ends with practice questions, new ones every time, and the lesson comes back later in spaced reviews.

Start Information Theory

Lessons that need something you haven't learned yet bring it in first, from any course.

Start your free trial14 days free. No card needed.