Squeeze: the Information Theory CapstoneSqueeze
0 / 0

Workbench / Squeeze: the Information Theory Capstone

Squeeze

Squeeze: the Information Theory Capstone

One project, built a chapter at a time: a working compressor. It starts as a meter that measures five very different files, grows a bit writer, a probability model, an entropy report, a Huffman coder, block and context models, integrity checks and error protection, and ends as an adaptive compressor that beats zlib on text and reports exactly how close it got to the limit. Every stage is measured on the same corpus, so you can see what each idea from the book is worth.

11 chapters◷ ~86 min to read ✓ 66 topics

How to read this book

Do each stage after its chapter. Answer the theory questions first, then build, run and compare your numbers with the ones shown. Keep everything in one folder: each stage imports the last, and the corpus never changes.

How to use this book

  1. Read one topic at a time. Each topic heading has a Done tick. Tick it only when you can explain the idea aloud without looking.
  2. Do the worked examples and practicals yourself before opening their solutions.
  3. Take the chapter quiz at the end. A score of 80% or more counts as passed. Wrong answers show the explanation, so re-read that topic and untick it if needed.

Contents

  1. S1 · B1·01The Information MeterStage 1 of Squeeze, the information theory capstone, after chapter 1: a test corpus of five very different files (Shakespeare, zeros, pseudo-random…6 min
  2. S2 · B1·02The Bit Writer and a Fixed-Length CodeStage 2 of Squeeze, after chapter 2: a bit writer and reader that pack values of any width into bytes, tested on 2,000 random sequences; a…8 min
  3. S3 · B1·03The Probability ModelStage 3 of Squeeze, after chapter 3: an order-0 model (how often each byte appears) and an order-1 model (how often each byte follows each other…6 min
  4. S4 · B1·04The Entropy ReportStage 4 of Squeeze, after chapter 4: for every corpus file, the entropy of the order-0 and order-1 models in bits per byte, the cost of sending each…6 min
  5. S5 · B1·05The Huffman CoderStage 5 of Squeeze, after chapter 5: a canonical Huffman coder for bytes, with a 128-byte table of codeword lengths in the header, written with stage…6 min
  6. S6 · B1·06Arithmetic Coding and the Method ChooserStage 6 of Squeeze, after chapter 6: an order-0 arithmetic coder (method 3) with a compact table of counts, which lands exactly on stage 4's order-0…7 min
  7. S7 · B1·07A Model with MemoryStage 7 of Squeeze, after chapter 7: an adaptive order-1 arithmetic coder (method 4) that predicts each byte from the one before it, learning 256…9 min
  8. S8 · B1·08Detecting DamageStage 8 of Squeeze, after chapter 8: every Squeeze file gets two CRC-32 checks, a frame check over the stored bytes that's verified before any…10 min
  9. S9 · B1·09Surviving the ChannelStage 9 of Squeeze, after chapter 9: `protect.py` wraps a Squeeze file in a correcting code (three copies of every bit, or Hamming(7,4)) for a noisy…11 min
  10. S10 · B1·10Real DataStage 10 of Squeeze, after chapter 10: the compressor meets real data of very different kinds (a genome, brain recordings, a compiled program, an MRI…7 min
  11. S11 · B1·11Mixing ModelsStage 11 of Squeeze, the last, after chapter 11: method 5 mixes order-0, order-1 and order-2 byte models, weighting each by how well it has been…10 min