Arithmetic Coding
Encode a sequence of symbols as a single nested rational interval within [0, 1).
Free theory articleEncode a sequence of symbols as a single nested rational interval within [0, 1).
Concept & interpretation
Instead of replacing each symbol with a fixed prefix code like Huffman coding,arithmetic coding represents an entire sequence of symbols as a single real number within the interval [0, 1). As the message grows longer, the interval grows smaller. Any number within that final bounded interval can be decoded to reconstruct the original message, provided the decoder knows the message length and the exact same probability model.
Interactive Experiment
You can test the previous derivation in the Arithmetic Coding module.
- Ensure the Message input is
AB. - Verify the Model is set to
2,1,1 (default). - Click Step to encode 'A'. The interval [0, 1/2) appears.
- Click Finish to encode 'B'. The interval [1/4, 3/8) appears.
- The results panel displays the final interval [1/4, 3/8), width 1/8, and the exact rational midpoint 5/16. Click Reset to rewind without changing Message or Model.