Entropy & Huffman
Measure the information in your own text and compress it with a Huffman code.
ChallengeWrite a sentence with entropy below 2 bits per symbol.
Preparing the instrument…
Read alongside
- EntropyInformation Theory
Measure the information in your own text and compress it with a Huffman code.
ChallengeWrite a sentence with entropy below 2 bits per symbol.
| Symbol | Share | Bar | Bits of surprise | Huffman code |
|---|---|---|---|---|
| ␣ | 15.2% | 2.72 | 101 | |
| e | 8.9% | 3.49 | 000 | |
| i | 8.9% | 3.49 | 001 | |
| a | 8.0% | 3.64 | 1101 | |
| n | 8.0% | 3.64 | 1110 | |
| r | 8.0% | 3.64 | 1111 | |
| o | 7.1% | 3.81 | 1000 | |
| t | 7.1% | 3.81 | 1001 | |
| s | 6.3% | 4 | 0111 | |
| c | 2.7% | 5.22 | 01001 | |
| f | 2.7% | 5.22 | 01010 | |
| m | 2.7% | 5.22 | 01011 | |
| u | 2.7% | 5.22 | 01100 | |
| d | 1.8% | 5.81 | 011011 | |
| g | 1.8% | 5.81 | 110000 | |
| h | 1.8% | 5.81 | 110001 | |
| l | 1.8% | 5.81 | 110010 | |
| p | 1.8% | 5.81 | 110011 | |
| , | 0.9% | 6.81 | 010000 | |
| b | 0.9% | 6.81 | 010001 | |
| y | 0.9% | 6.81 | 011010 |
Common symbols get short codes, rare ones long codes. No code is the start of another, so the bits decode without separators.