Skip to content
The Lumenary

Each worksheet prints cleanly on A4 or Letter. Answer keys are on a separate page.

The Lumenary · Advanced undergraduate

Information theory

Name: ______________________

Date: ______________________

You will learn to

  • Compute entropy, joint and conditional entropy, relative entropy and mutual information, and prove their basic inequalities from Gibbs' inequality
  • Prove Kraft's inequality, construct Huffman codes and prove that the optimal expected length L∗L^* of a prefix code satisfies H≤L∗<H+1H \le L^* < H + 1
  • Explain the asymptotic equipartition property and state Shannon's source coding theorem
  • Compute the capacity of the binary symmetric and erasure channels, and state the noisy-channel coding theorem and its converse
  • Distinguish Shannon information from meaning, and prove that no compressor can shorten every file
  1. 1.

    A source emits one of 88 symbols, all equally likely. What is its entropy, in bits?

  2. 2.

    A binary prefix code already contains the codewords 00 and 1010. What is the largest number of further codewords of length exactly 33 that can be added while keeping the code prefix-free?

  3. 3.

    Which statements about the mutual information I(X;Y)I(X; Y) of finite random variables are true? (Choose all that apply.)

    • A.I(X;Y)=I(Y;X)I(X; Y) = I(Y; X).
    • B.I(X;Y)≥0I(X; Y) \ge 0, with equality if and only if XX and YY are independent.
    • C.I(X;Y)≤min⁡(H(X),H(Y))I(X; Y) \le \min(H(X), H(Y)).
    • D.Applying a function gg to YY can increase the information it carries: I(X;g(Y))I(X; g(Y)) may exceed I(X;Y)I(X; Y).
  4. 4.

    In the proof of Gibbs' inequality we bound ∑xp(x)ln⁡q(x)p(x)≤∑x(q(x)−p(x))\sum_x p(x)\ln\frac{q(x)}{p(x)} \le \sum_x \big(q(x) - p(x)\big). Which fact justifies this step?

    • A.ln⁡t≤t−1\ln t \le t - 1 for all t>0t > 0, applied with t=q(x)/p(x)t = q(x)/p(x) and multiplied by p(x)≥0p(x) \ge 0.
    • B.ln⁡\ln is increasing.
    • C.∑xq(x)≤1\sum_x q(x) \le 1.
    • D.ln⁡t≥0\ln t \ge 0 for t≥1t \ge 1.
  5. 5.

    Build a Huffman code for four symbols with probabilities 0.4,0.3,0.2,0.10.4, 0.3, 0.2, 0.1. What is the expected codeword length, in tenths of a bit (so 1.51.5 bits would be 1515)?

  6. 6.

    A binary symmetric channel flips each bit independently with probability pp. For which values of pp is its capacity exactly 11 bit per use? (Choose all that apply.)

    • A.p=0p = 0
    • B.p=1p = 1
    • C.p=12p = \tfrac12
    • D.p=0.01p = 0.01
  7. 7.

    A start-up claims its lossless compressor shortens every file of exactly 10001000 bits by at least one bit. What is wrong?

    • A.There are 210002^{1000} such files but only 21000−12^{1000} - 1 files shorter than 10001000 bits, so two files would get the same output and could not both be recovered.
    • B.Nothing in principle: with a good enough model, every file can be compressed below its entropy.
    • C.It is possible, but the compressor would be too slow.
    • D.Only files with meaningful content can be compressed, and random files have no meaning.
  8. 8.

    Which Lean statement formalises Kraft's inequality for prefix codes? (u <+: v means u is a prefix of v.)

    • A.(hpf : ∀ u ∈ C, ∀ v ∈ C, u <+: v → u = v) : ∑ w ∈ C, (1 / 2 : ℝ) ^ w.length ≤ 1
    • B.(hpf : ∀ u ∈ C, ∀ v ∈ C, u <+: v → u = v) : ∑ w ∈ C, (1 / 2 : ℝ) ^ w.length = 1
    • C.(hpf : ∀ u ∈ C, ∀ v ∈ C, u ≠ v) : ∑ w ∈ C, (1 / 2 : ℝ) ^ w.length ≤ 1
    • D.(hpf : ∀ u ∈ C, ∀ v ∈ C, u <+: v → u = v) : ∑ w ∈ C, (2 : ℝ) ^ w.length ≤ 1
  9. 9.

    Write entropy(probs) returning −∑plog⁡2p-\sum p\log_2 p in bits (skipping zero probabilities), and kl(p, q) returning D(p ∥ q)=∑plog⁡2(p/q)D(p\,\|\,q) = \sum p\log_2(p/q) (also skipping terms with p=0p = 0). The tests check examples from the lesson, Gibbs' inequality on random distributions, and the asymmetry of relative entropy.

    Computational — Practice

Code: Apache-2.0 · Content: CC BY-SA 4.0