InformationTheory

InformationTheory.Shannon.Huffman.ExpectedLength

source

Expected length of the Huffman code #

The multiset-level cost huffmanCost aggregates the expected codeword length of huffmanLengthAux. Its merge-step recurrence and dependence only on the probability multiset are the machinery used in the optimality proof; expectedLength_eq_huffmanCost ties it back to the expected length of the published huffmanLength.

Main definitions #

  • huffmanCost — multiset-level expected length used in the cost-level optimality proof.

Main statements #

Cost-level recurrence for the optimality proof #

noncomputable def

InformationTheory.Shannon.Huffman.huffmanCost

source
{α : Type u_1} [DecidableEq α] [LinearOrder α] (s : Multiset (Finset α × )) :

Multiset-level expected length ∑_p p.2 * (∑_{a ∈ p.1} huffmanLengthAux s a) / p.1.card. Since depth is constant on each group, this equals ∑_p p.2 * depth(p). @audit:ok

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    Used by
      theorem

      InformationTheory.Shannon.Huffman.huffmanCost_step

      source
      {α : Type u_1} [DecidableEq α] [LinearOrder α] (s : Multiset (Finset α × )) (hs : 2 s.card) (hg : HuffmanGrouping s) :
      huffmanCost s = huffmanCost (↑(huffmanStep s hs hg)).2.2 + ((↑(huffmanStep s hs hg)).1.2 + (↑(huffmanStep s hs hg)).2.1.2)

      huffmanCost s = huffmanCost s'' + (x1.2 + x2.2) where s'' is the merged multiset. @audit:ok

      Used by
        theorem

        InformationTheory.Shannon.Huffman.huffmanCost_eq_zero_of_base

        source
        {α : Type u_1} [DecidableEq α] [LinearOrder α] (s : Multiset (Finset α × )) (h : s.card 1) (hg : HuffmanGrouping s) :

        huffmanCost s = 0 when s.card ≤ 1. @audit:ok

        Used by
          theorem

          InformationTheory.Shannon.Huffman.huffmanCost_eq_of_prob_multiset

          source

          huffmanCost depends only on the probability multiset s.map Prod.snd. @audit:ok

          Used by
            theorem

            InformationTheory.Shannon.Huffman.expectedLength_eq_huffmanCost

            source

            expectedLength P (huffmanLength P) = huffmanCost (initMultiset P). @audit:ok

            Used by