-2

enter image description here

enter image description here

How to calculate expected code length?

  • This question belongs to Math or even better Theoretical Computer Science stack exchange. – Michel Keijzers Apr 22 '20 at 13:14
  • 3
    The calculation is done for you, right before your eyes. Which part don't you understand? – Neil_UK Apr 22 '20 at 13:16
  • I don't understand how there are two times 0.25 and 0.2 –  Apr 22 '20 at 13:32
  • The five 2-length codewords have probabilities 0.25, 0.25 and 0.2. The two 3-length codewords each have probability 0.15, all given in the table at the top. The contribution of each codeword to the expected length is length*probability, so the total expected length is the sum of all these expectations. The terms have been grouped in a straightforward way, which unfortunately makes the sum slightly less obvious – Neil_UK Apr 22 '20 at 14:05

1 Answers1

2

enter image description here

Should be: $$L = \sum p_i l_i = (0.25 + 0.25 + 0.2) \times 2 + (0.15 + 0.15) \times 3 = 2.3 $$