A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Data Compression Basics

Graduate Depth 94 in the knowledge graph ☐ I know this ☆ Set as goal
2topics build on this
416prerequisites beneath it
See this on the map →
Huffman CodingSource Coding Theorem+1 more→→Rate-Distortion Theory
data compression lossless lossy redundancy LZ77 entropy coding

Core Idea

Data compression reduces the number of bits needed to represent information by exploiting redundancy. Lossless compression (Huffman, arithmetic, LZ77, LZ78) allows perfect reconstruction and is bounded by the source entropy. Lossy compression (JPEG, MP3, H.264) sacrifices some fidelity for much higher compression ratios, governed by rate-distortion theory. Practical compressors combine a model (which identifies redundancy and predicts symbols) with a coder (which converts predictions into a compact bitstream). The model captures statistical structure; the coder approaches the entropy of the model's predictions.

Explainer

Data compression is the practical application of Shannon's source coding theorem. The theorem tells you the limit (entropy); compression algorithms try to approach it. Understanding compression requires separating two concerns: the model (what statistical structure does the data have?) and the coder (how do we turn predicted statistics into bits?).

Lossless compression guarantees perfect reconstruction. Entropy coding (Huffman, arithmetic) is the coder; it converts symbol probabilities into near-optimal bit assignments. But the entropy of raw bytes is high. The model's job is to reduce the effective entropy by capturing redundancy. LZ77 (used in gzip, DEFLATE) captures repeated substring patterns by replacing them with backward references. LZ78/LZW (used in classic GIF) builds a dictionary of seen patterns. PPM (prediction by partial matching) uses character-level context to predict the next symbol. Burrows-Wheeler Transform (used in bzip2) rearranges data to group similar characters together, making the result more compressible by subsequent entropy coding.

Lossy compression allows controlled degradation of the reconstructed output. JPEG transforms image blocks into frequency coefficients (via DCT), quantizes them (the lossy step — small coefficients are zeroed), and entropy-codes the result. MP3 uses a psychoacoustic model to identify sounds the human ear cannot perceive, then removes them. H.264/H.265 video codecs combine motion prediction (modeling temporal redundancy) with spatial prediction and quantization. In each case, the lossy step reduces the effective entropy of what remains, allowing the entropy coder to produce a much smaller output than any lossless method could.

The information-theoretic perspective unifies these: every compressor is trying to approach the entropy of the source (lossless) or the rate-distortion function (lossy). The gap between a compressor's output size and the theoretical limit reveals inefficiency — either the model is not capturing all the redundancy, or the coder is not converting predictions to bits efficiently. Modern machine-learned compressors (neural codecs for images, audio, and video) demonstrate that better models consistently yield better compression, validating the information-theoretic framework. Shannon's theorems do not just provide limits; they provide a blueprint.

Practice Questions 3 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Dividing Integers → Unit Rates → Proportions → Percent Concept → Converting Between Fractions, Decimals, and Percents → Operations with Rational Numbers → Two-Step Equations → Solving Multi-Step Equations → Equations with Variables on Both Sides → Angle Pairs: Complementary, Supplementary, and Vertical → Parallel Lines and Transversals → Corresponding Angles → Alternate Interior Angles → Triangle Angle Sum Theorem → Exterior Angle Theorem → Triangle Inequality Theorem → Similar Triangles: AA Similarity → Similar Triangles: SSS and SAS Similarity → Proportions in Similar Triangles → Right Triangle Trigonometry Introduction → Sine, Cosine, and Tangent Ratios → Trigonometric Ratios Review → Radian Measure → Converting Between Degrees and Radians → The Unit Circle → Graphing Sine and Cosine → Graphing Tangent and Reciprocal Trigonometric Functions → Derivatives of Trigonometric Functions → Antiderivatives → Indefinite Integrals → Basic Integration Rules → Riemann Sums → Definite Integral Definition → Probability Density Functions and Continuous Distributions → Cumulative Distribution Functions → Continuous Random Variables → Probability Density Functions → Expected Value → Shannon Entropy → Source Coding Theorem → Huffman Coding → Arithmetic Coding → Data Compression Basics

Longest path: 95 steps · 416 total prerequisite topics

Prerequisites (3)

Leads To (1)