Code-distribution correspondence (source code)

= Code-distribution correspondence

Lengths of a binary prefix code satisfy $K=\sum_x2^{-L(x)}\leq1$ and therefore define the probability mass function $R(x)=2^{-L(x)}/K$. Conversely, a mass function gives ideal lengths $-\log_2R(x)$ and integer prefix lengths after rounding.