DATA COMPRESSION SIMULATION

No algorithm can compress every file: if every string got shorter, two different strings would have to share one output and decompression could not tell which to restore. The real ceiling is the Shannon entropy of the symbol distribution. When one symbol dominates, the Huffman tree leans hard to one side and that symbol earns a code of a single bit; when all symbols occur equally often, entropy hits its maximum of log₂N, every code ends up the same length and there is nothing left to gain. Images and audio get further only by throwing away detail the eye and ear barely notice.

▸ Counting source symbol frequencies…
▸ Building a priority queue by frequency
▸ Building the Huffman tree (merge the 2 smallest)…
▸ Assigning prefix codes 0/1 along the edges
▸ Computing Shannon entropy H = −Σ p·log₂p
▸ Ready — Online. ✅
0%
⌂ Mind & Machine

Simulation room Data Compression

Data Compression & Huffman Coding
Online
Huffman · entropy · ratio
Compression gauge
🗜️ Compression ratio
Raw bits—
Compressed bits—
Ratio—
Entropy H—
Avg code length—
Symbols—
Notes
The Huffman tree gives a short code to common symbols and a long code to rare ones → the average bits approach the entropy H — the theoretical limit of lossless compression.
—
Pick a ‘Scenario’ (skewed / uniform / runs / lossy…) · click a symbol or concept for details
Your browser has canvas disabled.
Actual vs ideal (Shannon) bits per symbol actual bits (Huffman code)ideal bits −log₂(p)
About Data Compression

No algorithm can compress every file: if every string got shorter, two different strings would have to share one output and decompression could not tell which to restore. The real ceiling is the Shannon entropy of the symbol distribution. When one symbol dominates, the Huffman tree leans hard to one side and that symbol earns a code of a single bit; when all symbols occur equally often, entropy hits its maximum of log₂N, every code ends up the same length and there is nothing left to gain. Images and audio get further only by throwing away detail the eye and ear barely notice.

Related topics in Mind & Machine