The Cost of Using a Code for Another Distribution

A code emphasizing common symbols in one source can perform poorly when the recipient data has different frequencies.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Trace changed probabilities
  2. Choose data for a size comparison
  3. Measure weighted lengths after probabilities change
  4. Compare improvements with adaptation cost

Trace changed probabilities

If A receives one bit and B receives four, the expected contribution grows when B becomes common. The lengths remain unchanged. See variable lengths and expected cost.

Choose data for a size comparison

Measure complete outputs on samples with a representative distribution. An observed small payload does not establish the same gains elsewhere. Empirical distributions make that evidence explicit.[1][2]

Measure weighted lengths after probabilities change

Use a code with A length one and B, C length two. If A occurs three quarters of the time, expected length is 1.25. If A occurs only one quarter, expected length rises to 1.75 with the same code. See expected code length.

A frequency .75 → .75×1 + .25×2 = 1.25
A frequency .25 → .25×1 + .75×2 = 1.75
Valid code, different efficiency

Compare improvements with adaptation cost

Updating a dictionary or code model can introduce extra metadata. Analyze several representative blocks and include complete sizes. For small blocks, a shared fixed dictionary can cost less overall even when its bit rate is worse.

References

  1. Claude E. Shannon, A Mathematical Theory of Communication ↩
  2. David J. C. MacKay, Information Theory, Inference, and Learning Algorithms ↩