Probabilities, codewords and live stream
Entropy versus average code length

Shannon Source Coding: Symbol Probabilities, Huffman Codewords and Entropy Bound (2D)

Build a symbol source and watch the best prefix code for it. Choose the alphabet size and how skewed the probabilities are (Zipf-like), and the Huffman algorithm assigns short codewords to common symbols and long ones to rare symbols. A stream of sampled symbols is encoded live; its measured bits per symbol converges to the exact Huffman average length, which always sits between the entropy H and H + 1. Block extension shows how coding pairs and triples closes the gap. A Blender-built encoder and numerical checks are included.

Made with 🟠 Blender