Optimal source code (source code)

= Optimal source code
{title2=$\min\sum_a p_a\ell_a$}

= Optimal code
{synonym}

For a fixed source distribution and code alphabet, an optimal <uniquely decodable code> minimizes expected codeword length. <Huffman coding> gives an optimal binary <prefix code>, and the equivalence of attainable uniquely-decodable and prefix-code lengths gives the same minimum for both classes.