Shannon Entropy & Frequency Profiler
Computes empirical symbol frequency histograms f(c), validates probability distributions p_i = f(c)/n, and calculates theoretical Shannon source entropy H(X) = -∑ p_i log₂(p_i).
To investigate the theoretical foundations and microarchitectural mechanics of optimal lossless prefix coding, evaluate David Huffman's greedy tree construction via Min-Heap priority queues against Shannon entropy limits H(X), verify instantaneous decodability and the Kraft-McMillan inequality, and empirically demonstrate the linear compression scaling law B(n) = L_bar · n + B_0 = 2.5000 · n + 64.0000 bits across input stream sizes n ∈ [500, 50000] symbols. Explore interactive search algorithms, compare operation counts and analyse complexity scaling.
Ready to execute stream length benchmark.
Adjust stream length n, then execute benchmark.
Operation counts are generated deterministically by the exact algorithmic execution model. Modern hardware benchmarks additionally reflect cache line prefetching and branch misprediction penalties.
The simulated execution environment models idealized scalar CPU bitstream packing where each symbol emits its exact theoretical Huffman codeword length L_bar = 2.5000 bits. In physical microprocessor hardware, observable compression latency and memory bus throughput are modulated by CPU L1/L2 cache locality of translation tables, branch mispredictions during bitstream bit-testing loops, bit-accumulator flush boundaries (32-bit vs 64-bit words), and vectorization capabilities of hardware SIMD units. In the Huffman lossless compression benchmark across raw text stream lengths n in [500, 50000] symbols generated under a standardized 8-symbol stationary probability distribution (entropy H(X) = 2.45 bits/symbol, theoretical average Huffman code length L_bar = 2.5000 bits/symbol), each incoming symbol is translated into its variable-length prefix code. Across n independent identically distributed symbols, total emitted payload bits scale deterministically as 2.5000 · n bits. Adding B_0 = 64.0000 bits for the canonical codebook header (storing symbol bit lengths for 8 symbols at 8 bits per length) yields the exact linear relation B(n) = 2.5000 · n + 64.0000 bits. Ordinary least-squares regression across all benchmark trials yields an ideal coefficient of determination R² = 1.000000 with zero residual variance.
Computes empirical symbol frequency histograms f(c), validates probability distributions p_i = f(c)/n, and calculates theoretical Shannon source entropy H(X) = -∑ p_i log₂(p_i).
Maintains intermediate subtree weights in a continuous binary heap array, executing Extract-Min and Insert operations in O(log |Σ|) steps to drive greedy code tree synthesis.
Iteratively links lowest-frequency subtrees into composite nodes with left (0) and right (1) branches, producing an optimal full binary trie with |Σ| leaves and |Σ| - 1 internal nodes.
Transforms arbitrary Huffman trees into canonical prefix codes sorted by bit length and lexicographical order, reducing codebook transmission overhead to a 64-bit length table.
Translates input symbol sequences into variable-length binary codewords, packing bits into 64-bit processor registers and emitting packed byte arrays with zero padding leakage.
Performs bit-by-bit walks down the decoding trie, confirming instantaneous symbol emission upon reaching leaf nodes and validating the Kraft-McMillan inequality.
To investigate the theoretical foundations and microarchitectural mechanics of optimal lossless prefix coding, evaluate David Huffman's greedy tree construction via Min-Heap priority queues against Shannon entropy limits H(X), verify instantaneous decodability and the Kraft-McMillan inequality, and empirically demonstrate the linear compression scaling law B(n) = L_bar · n + B_0 = 2.5000 · n + 64.0000 bits across input stream sizes n ∈ [500, 50000] symbols. Suggested independent settings: 500, 1000, 2000, 5000, 10000, 20000, 50000 symbols.
Initialize the test bench and generate a stationary text stream of designated length n symbols drawn from the calibrated 8-symbol vocabulary with average code length L_bar = 2.5000 bits/symbol.
Profile symbol frequencies f(c) using the Frequency Profiler, instantiate a leaf node for each distinct symbol, and insert all |Σ| = 8 nodes into the Min-Heap priority queue.
Execute the Huffman greedy tree construction loop: repeatedly pop the two minimum-weight nodes from the heap, create an internal parent node with weight equal to their sum, link the children as 0 (left) and 1 (right), and push the parent back into the heap until a single root node remains.
Traverse the completed Huffman binary tree from root to leaves via depth-first search to generate the binary codeword table. Verify the Prefix Property: confirm that no generated codeword is a prefix of another.
Feed the raw text stream into the Bitstream Bit-Packer, concatenate the variable-length codewords into a continuous binary stream, prepend the B_0 = 64-bit canonical header table, and record the exact total compressed bitstream length B(n).
Repeat the benchmarking protocol across input lengths n ∈ [500, 1000, 2000, 5000, 10000, 20000, 50000] symbols. Perform ordinary least-squares linear regression of B(n) against n to extract the empirical average code length L_bar and header intercept B_0.
Points are your recorded benchmark observations. The regression line validates Huffman Coding & Compression complexity scaling.
| # | Raw input text stream length n (symbols) (symbols) | Compressed bitstream size B(n) (bits) | Raw input text stream length n (symbols) | Compressed bitstream length B(n) = 2.5000 · n + 64.0000 (bits) | Remove |
|---|
No readings yet. Execute a stream length benchmark and record it.