What does Lazy Tool Hubs conclude, in numbers, about “The Linear Bill: Context Cost of Loading Everything and the Entropy Bound”?
Answer: At exponent zero the entropy is 8.229 bits and the Huffman tree needs 8.293 decisions, a saving of only 0.079 of the balanced tree's cost: when all tools are equally used, frequency has nothing to sort. At exponent one the entropy is 6.372, the Huffman tree needs 6.406, a gap of 0.034, and the saving over the balanced tree is 0.288. At exponent two the entropy is only 2.324, the Huffman tree needs 2.379, and the saving is 0.736. In all five rows the gap between the Huffman tree and the entropy is at most 0.065, far below the one unit that Shannon's theorem allows. The last two columns concern an 8-ary tree: counting three binary choices as one eight-way choice, the entropy at exponent one equals 2.124 eight-way choices, while the 8-ary Huffman tree needs 2.207.
Scope of the numbers: Selection accuracy lacks reliable peer-reviewed primary evidence and is demoted to an author's hypothesis. Marked boxes separate published evidence, runnable Python calculations (17 programs), classical sources and the author's hypotheses.
Data table
The numbers below are printed verbatim by the chapter's Python program and can be reproduced by running it. standard-library Python onlyprinted values that match the answer: 0.034, 0.065, 0.079, 0.288, 0.736, 2.124
| a H bits L Huff L-H balanced saved H/3 L8 | ||||||
| 0.0 | 8.229 | 8.293 | 0.065 | 9 | 0.079 | 2.743 2.900 |
| 0.6 | 7.747 | 7.777 | 0.030 | 9 | 0.136 | 2.582 2.651 |
| 1.0 | 6.372 | 6.406 | 0.034 | 9 | 0.288 | 2.124 2.207 |
| 1.4 | 4.408 | 4.468 | 0.061 | 9 | 0.504 | 1.469 1.597 |
| 2.0 | 2.324 | 2.379 | 0.056 | 9 | 0.736 | 0.775 1.139 |
Show the full program
# Chapter 1. p12: how close a Huffman tree comes to the entropy bound.
# For N = 300 tools with Zipf call shares of exponent a, compare the
# entropy H (bits), the expected number of binary routing decisions L
# of the Huffman tree (Huffman 1952), and a balanced tree that ignores
# frequency (ceil(log2 N) decisions). Shannon's bound: H <= L < H + 1.
# The same for an 8-ary tree, measured in 8-way decisions (H / 3).
# Exponents are illustrative; a = 0 means every tool is equally used.
import heapq
import math
N = 300
def zipf(n, a):
w = [1.0 / (i ** a) for i in range(1, n + 1)]
t = math.fsum(w)
return [x / t for x in w]
def entropy(p):
return -math.fsum(x * math.log2(x) for x in p if x > 0)
def huffman_depths(p, k):
items = [(x, i, (i,)) for i, x in enumerate(p)]
seq, pad = len(p), 0
while k > 2 and (len(items) + pad - 1) % (k - 1):
pad += 1
for _ in range(pad):
items.append((0.0, seq, ()))
seq += 1
heapq.heapify(items)
depth = [0] * len(p)
while len(items) > 1:
kids = [heapq.heappop(items) for _ in range(min(k, len(items)))]
leaves = ()
for c in kids:
for i in c[2]:
depth[i] += 1
leaves += c[2]
heapq.heappush(items, (math.fsum(c[0] for c in kids), seq, leaves))
seq += 1
return depth
bal = math.ceil(math.log2(N))
print(" a H bits L Huff L-H balanced saved H/3 L8")
for a in (0.0, 0.6, 1.0, 1.4, 2.0):
p = zipf(N, a)
h = entropy(p)
d2 = huffman_depths(p, 2)
d8 = huffman_depths(p, 8)
l2 = math.fsum(x * d for x, d in zip(p, d2))
l8 = math.fsum(x * d for x, d in zip(p, d8))
print("%4.1f %8.3f %7.3f %6.3f %7d %8.3f %6.3f %5.3f"
% (a, h, l2, l2 - h, bal, 1 - l2 / bal, h / 3, l8))Single source and citation
Fan, Y. (2026). A Lazy-Loading Private Tool Hub: Near-Zero Opening Context for Hundreds of Checkers and On-Demand Routing Trees (Version 1.0.0), Chapter 1: The Linear Bill: Context Cost of Loading Everything and the Entropy Bound. 5D Library. DOI pending
DOI pending · monograph page goes live after publication · 5DL-B-257 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026257,
author = {Fan, Yafu},
title = {A Lazy-Loading Private Tool Hub: Near-Zero Opening Context for Hundreds of Checkers and On-Demand Routing Trees},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
note = {DOI pending}
}Other chapter answers in this book
- Chapter 2 · Building Huffman Trees: Many-Way Merging, Dummy Leaves and the Price of a Menu
- Chapter 3 · Navigable Trees: the Price of Alphabetic Order and the Accumulation of Wrong Turns
- Chapter 4 · The Branching Factor: Depth against Width, and Hanging Popular Tools on the Root
- Chapter 5 · Queueing with Cold Starts: the Delay Bill of Lazy Loading and How Long to Stay Warm
- Chapter 6 · Frequency Drift: the Cost of Wrong Frequencies and When to Rebuild the Routing Tree
- Chapter 7 · Classical Sources East and West: Offices and Duties in the Rites of Zhou and Dewey's Decimal Scheme
- Chapter 8 · Closing the Loop: a Monthly Report on Catalogue Layering and Call Frequency