Extended Science

Source coding theorem

Definition

Lossless compression floors at the source's entropy: average code length can never run under entropy, and squeezing past it always distorts.

Core rule: Use entropy to judge how much headroom a compressor has left and to spot "lossless universal compression" scams; it also tells you that to compress further you must give up losslessness (go to lossy compression).

You have four letters to send, so you could set aside two bits for every letter. But one letter keeps turning up, and two barely show. Do you really need to spend two places on each of them? Claude Shannon laid out those four letters in a paper and worked through the bill.

The source coding theorem tells you the smallest average cost you can approach when the reader has to recover every symbol exactly. Let's change Shannon's price list and see what saves space. Then we'll try to use the same limit on files of our own.

How it works

First look at what Shannon put on the table: a source that gives him one letter at a time. Each choice is independent of the last. The first letter comes up half the time, the second a quarter, and the remaining two an eighth each.

In his 1948 paper, Shannon writes a single zero next to the most common letter. The second gets one zero, and the last two get one one zero and one one one. A bit is one position that holds a zero or a one. Join the codes together to send the message.

  1. 01 · Messages have uncertainty Each message has a different probability of appearing; the overall uncertainty is entropy.
  2. 02 · Codes must be distinguishable Lossless reconstruction requires each message to have a unique code.
  3. +2 more mechanism steps & animation in the app

When it fails & limits

Before you apply that floor, ask which messages you meant to count. An encoder can have a very different day with one file than with another file the same size.

✦ Unlock full lesson in ConceptFlow

Unlock the full Source coding theorem lesson in ConceptFlow

You’ve read the core idea and opening case. Get the ConceptFlow app to continue through the full breakdown, failure modes, 5-minute audio lesson, and decision practice.

  • ▸5-minute English & Mandarin audio lesson
  • ▸4 more deep-dive case & mechanism insights
  • ▸All 4 failure boundaries & counter-examples
  • ▸4-point decision checklist + 6-step practice

Tap a store button on mobile, or scan with your phone camera on desktop.