Difference between revisions of "Exercise 2.12: Run–Length Coding and Run–Length Limited Coding"

From LNTwww
 
(12 intermediate revisions by 4 users not shown)
Line 1: Line 1:
  
{{quiz-Header|Buchseite=Informationstheorie/Weitere Quellencodierverfahren
+
{{quiz-Header|Buchseite=Information_Theory/Further_Source_Coding_Methods
 
}}
 
}}
  
[[File:EN_Inf_A_2_13.png|right|frame|Tabelle zu Run–Length Coding]]
+
[[File:EN_Inf_A_2_13.png|right|frame|Table on Run-Length Coding]]
Wir betrachten eine Binärquelle mit dem Symbolvorrat  $\rm A$  und  $\rm B$, wobei  $\rm B$  allerdings nur sehr selten auftritt.
+
We consider a binary source with the symbol set  $\rm A$  and  $\rm B$, where  $\rm B$  however, occurs only very rarely.
  
* Ohne Quellencodierung würde man pro Quellensymbol genau ein Bit benötigen, und dementsprechend würde bei einer Quellensymbolfolge der Länge  $N$  für die Codebitfolge ebenfalls  $N_\text{Bit} = N$  gelten.
+
* Without source coding, exactly one bit would be needed per source symbol, and accordingly, for a source symbol sequence of length  $N$ , the encoded sequence would also have length   $N_\text{bits} = N$.
* Entropiecodierung macht hier ohne weitere Maßnahme  (Beispiel:  Zusammenfassen mehrerer Symbole zu einem Tupel) wegen der ungünstigen Symbolwahrscheinlichkeiten wenig Sinn.
+
* Entropy coding makes little sense here without further measures  (example:  combining several symbols into a tuple)  because of the unfavourable symbol probabilities.
* Abhilfe schafft  [[Information_Theory/Weitere_Quellencodierverfahren#Laufl.C3.A4ngencodierung_.E2.80.93_Run.E2.80.93Length_Coding|Run-Length Coding]]  $(\rm RLC)$, das unter dem genannten Link im Theorieteil beschrieben ist.  Zum Beispiel ergibt sich für die Symbolfolge   $\rm ABAABAAAABBAAB\text{...}$   die entsprechende Ausgabe von ''Run–Lenght Coding'':   $ 2; \ 3; \ 5; \ 1; \ 3; \text{...}$
+
* The remedy is  [[Information_Theory/Weitere_Quellencodierverfahren#Run.E2.80.93Length_coding|Run-Length Coding]]  $(\rm RLC)$, which is described in the theory section under the link mentioned.  For example, for the symbol sequence   $\rm ABAABAAAABBAAB\text{...}$   the corresponding output of  "Run–Length Coding":   $ 2; \ 3; \ 5; \ 1; \ 3; \text{...}$
* Natürlich muss man die Längen  $L_1 = 2$,  $L_2 = 3$, ...  der einzelnen, jeweils durch  $\rm B$  getrennten Substrings vor der Übertragung binär darstellen.  Verwendet man für alle  $L_i$  jeweils  $D = 3$  (Bit), so erhält man die RLC–Binärfolge
+
* Of course, the lengths  $L_1 = 2$,  $L_2 = 3$, ...  of the individual substrings, each separated by  $\rm B$ , must be represented in binary before transmission.  If one uses  $D = 3$  (bit) for all  $L_i$  one obtains the RLC binary symbol sequence
 
:$$010\hspace{0.05cm}\text{'}\hspace{0.05cm}011\hspace{0.05cm}\text{'}\hspace{0.05cm}101\hspace{0.05cm}\text{'}\hspace{0.05cm}001\hspace{0.05cm}\text{'}\hspace{0.05cm}011\hspace{0.05cm}\text{'}\hspace{0.05cm}\text{...}$$
 
:$$010\hspace{0.05cm}\text{'}\hspace{0.05cm}011\hspace{0.05cm}\text{'}\hspace{0.05cm}101\hspace{0.05cm}\text{'}\hspace{0.05cm}001\hspace{0.05cm}\text{'}\hspace{0.05cm}011\hspace{0.05cm}\text{'}\hspace{0.05cm}\text{...}$$
  
Die Grafik zeigt das  das zu analysierende RLC–Ergebnis.  In Spalte 2 und 3 sind die Substringlängen  $L_i$  binär bzw. dezimal angegeben und in Spalte 4 in kumulierter Form  (Werte von Spalte 3 aufsummiert).
+
The graph shows the RLC result to be analyzed.  Columns 2 and 3 show the substring lengths  $L_i$  in binary and decimal, respectively, and column 4 shows them in cumulative form  (values from column 3 added up).
  
*Ein Problem von ''Run-Length Coding''  $\rm (RLC)$ ist der  unbegrenzte Wertebereich der Größen  $L_i$.  Mit  $D = 3$  kann kein Wert  $L_i > 7$  dargestellt werden und mit  $D = 2$  lautet die Beschränkung  $1 \le L_i \le 3$.
+
*One problem of  "Run-Length Coding"  $\rm (RLC)$ is the unlimited range of values of the quantities  $L_i$.  With  $D = 3$,  no value  $L_i > 7$  can be represented and with  $D = 2$,  the restriction is  $1 \le L_i \le 3$.
  
*Das Problem umgeht man mit <i>Run&ndash;Length Limited Coding</i>&nbsp; $\rm (RLLC)$.&nbsp; Ist ein Wert&nbsp; $L_i \ge 2^D$, so ersetzt man&nbsp; $L_i$&nbsp; durch ein Sonderzeichen&nbsp; <b>S</b>&nbsp; und die Differenz&nbsp; $L_i - 2^D +1$.&nbsp; Beim RLLC&ndash;Decoder wird dieses Sonderzeichen&nbsp; <b>S</b>&nbsp; wieder expandiert.
+
*The problem is circumvented with&nbsp; "Run&ndash;Length Limited Coding"&nbsp; $\rm (RLLC)$.&nbsp; If a value is&nbsp; $L_i \ge 2^D$,&nbsp; one replaces&nbsp; $L_i$&nbsp; with a special character&nbsp; <b>S</b>&nbsp; and the difference&nbsp; $L_i - 2^D +1$.&nbsp; With the RLLC decoder, this special character&nbsp; <b>S</b>&nbsp; is expanded again.
  
  
Line 25: Line 25:
  
  
''Hinweise:''
+
Hints:  
*Die Aufgabe gehört zum  Kapitel&nbsp; [[Information_Theory/Weitere_Quellencodierverfahren|Weitere Quellencodierverfahren]].
+
*This exercise belongs to the chapter&nbsp; [[Information_Theory/Further_Source_Coding_Methods|Further source coding methods]].
*Insbesondere wird  Bezug genommen auf die Seite&nbsp; [[Information_Theory/Weitere_Quellencodierverfahren#Laufl.C3.A4ngencodierung_.E2.80.93_Run.E2.80.93Length_Coding|Lauflängencodierung &ndash; Run-Length Coding]].
+
*In particular, reference is made to the section&nbsp; [[Information_Theory/Further_Source_Coding_Methods#Run.E2.80.93Length_coding|Run-Length Coding]].
 
   
 
   
  
  
 
{{GraueBox|
 
{{GraueBox|
TEXT=$\text{RLLC-Beispiel}$:&nbsp; Wir gehen wieder von obiger Folge und dem Parameter&nbsp; $D = 2$&nbsp; aus:
+
TEXT=$\text{RLLC Example}$:&nbsp; We again assume the above sequence and the parameter&nbsp; $D = 2$&nbsp;:
* Quellensymbolfolge: &nbsp;&nbsp; $\rm ABAABAAAABBAAB$...
+
* Source symbol sequence: &nbsp;&nbsp; $\rm ABAABAAAABBAAB$...
* RLC&ndash;Dezimalfolge: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'''2; 3; 5; 1; 3;''' ...
+
* RLC decimal sequence: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'''2; 3; 5; 1; 3;''' ...
* RLLC&ndash;Dezimalfolge: &nbsp;&nbsp;&nbsp; '''2;&nbsp; 3;&nbsp;'''<font color="#cc0000"><span style="font-weight: bold;"> S;</span></font>'''&nbsp;2;&nbsp; 1;&nbsp; 3;''' ...
+
* RLLC decimal sequence: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '''2;&nbsp; 3;&nbsp;'''<font color="#cc0000"><span style="font-weight: bold;"> S;</span></font>'''&nbsp;2;&nbsp; 1;&nbsp; 3;''' ...
* RLLC&ndash;Binärfolge: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '''01&prime;11&prime;''' <font color="#cc0000"><span style="font-weight: bold;">00&prime;</span></font>'''10&prime;01&prime;11&prime;'''...
+
* RLLC binary sequence: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '''10&prime;11&prime;''' <font color="#cc0000"><span style="font-weight: bold;">00&prime;</span></font>'''10&prime;01&prime;11&prime;'''...
  
  
Man erkennt:  
+
You can see:
*Das Sonderzeichen&nbsp; <b>S</b>&nbsp; ist hier als&nbsp; <b>00</b>&nbsp; binär&ndash;codiert.&nbsp; Dies ist nur ein Beispiel &ndash; es muss nicht so sein.  
+
*The special character&nbsp; <b>S</b>&nbsp; is binary-coded here as&nbsp; <b>00</b>&nbsp;.&nbsp; This is only an example &ndash; it does not have to be like this.
*Da mit&nbsp; $D = 2$&nbsp; für alle echten RLC&ndash;Werte&nbsp; $1 \le L_i \le 3$&nbsp; gilt, erkennt der Decoder das Sonderzeichen&nbsp; '''00'''.
+
*Since with&nbsp; $D = 2$&nbsp; for all real RLC values&nbsp; $1 \le L_i \le 3$&nbsp;, the decoder recognizes the special character&nbsp; '''00'''.
*Er  ersetzt dieses wieder durch&nbsp; $2^D -1$&nbsp;  (im Beispiel drei)&nbsp; $\rm A$&ndash;Symbole.}}
+
*It replaces this again with&nbsp; $2^D -1$&nbsp;  (three in the example)&nbsp; $\rm A$&ndash;symbols.}}
  
  
  
===Fragebogen===
+
===Questions===
  
 
<quiz display=simple>
 
<quiz display=simple>
{Wieviele Bit würde man&nbsp; <u>ohne Quellencodierung</u>&nbsp; benötigen, also mit der Zuordnung&nbsp; $\rm A$ &nbsp; &#8594; &nbsp;<b>0</b>&nbsp; und&nbsp; $\rm B$ &nbsp; &#8594; &nbsp;<b>1</b>?
+
{How many bits would be needed&nbsp; <u>without source coding</u>&nbsp;, i.e. with the assignment&nbsp; $\rm A$ &nbsp; &#8594; &nbsp;<b>0</b>&nbsp; and&nbsp; $\rm B$ &nbsp; &#8594; &nbsp;<b>1</b>?
 
|type="{}"}
 
|type="{}"}
$N_\text{Bit} \ = \ $  { 1250 }
+
$N_\text{bits} \ = \ $  { 1250 }
  
  
{Wie groß ist die relative Häufigkeit des Symbols&nbsp; $\rm B$?
+
{What is the relative frequency of symbol&nbsp; $\rm B$?
 
|type="{}"}
 
|type="{}"}
 
$h_{\rm B}\ = \ $ { 2 3% } $\ \%$
 
$h_{\rm B}\ = \ $ { 2 3% } $\ \%$
  
  
{Wie viele Bit benötigt man für&nbsp; <u>Run&ndash;Length Coding</U>&nbsp; $\rm (RLC)$&nbsp; nach der angegebenen Tabelle mit acht Bit pro Codewort&nbsp; $(D = 8)$?
+
{How many bits are needed for&nbsp; <u>Run&ndash;Length Coding</U>&nbsp; $\rm (RLC)$&nbsp; according to the given table with eight bits per code word&nbsp; $(D = 8)$?
 
|type="{}"}
 
|type="{}"}
$N_\text{Bit} \ = \ $ { 200 }  
+
$N_\text{bits} \ = \ $ { 200 }  
  
  
{Ist hier&nbsp; <u>Run&ndash;Length Coding</u>&nbsp; mit sieben Bit&ndash;Codeworten&nbsp; $(D = 7)$&nbsp; möglich?
+
{Is&nbsp; <u>Run&ndash;Length Coding</u>&nbsp; with seven bit code words&nbsp; $(D = 7)$&nbsp; possible here?
 
|type="()"}
 
|type="()"}
- Ja.
+
- Yes.
+ Nein.
+
+ No.
  
  
{Wie viele Bit benötigt man für&nbsp; <u>Run&ndash;Length Limited Coding</U>&nbsp; $\rm (RLLC)$&nbsp; mit sieben Bit pro Codewort&nbsp; $(D = 7)$?
+
{How many bits are needed for&nbsp; <u>Run&ndash;Length Limited Coding</U>&nbsp; $\rm (RLLC)$&nbsp; with seven bits per code word&nbsp; $(D = 7)$?
 
|type="{}"}
 
|type="{}"}
$N_\text{Bit} \ = \ $ { 182 }
+
$N_\text{bits} \ = \ $ { 182 }
  
  
{Wie viele Bit benötigt man für&nbsp; <u>Run&ndash;Length Limited Coding</u>&nbsp; $\rm (RLLC)$&nbsp; mit sechs Bit pro Codewort&nbsp; $(D = 6)$?
+
{How many bits are needed for&nbsp; <u>Run&ndash;Length Limited Coding</u>&nbsp; $\rm (RLLC)$&nbsp; with six bits per code word&nbsp; $(D = 6)$?
 
|type="{}"}
 
|type="{}"}
$N_\text{Bit} \ = \ ${ 204 }
+
$N_\text{bits} \ = \ ${ 204 }
  
  
Line 83: Line 83:
 
</quiz>
 
</quiz>
  
===Musterlösung===
+
===Solution===
 
{{ML-Kopf}}
 
{{ML-Kopf}}
'''(1)'''&nbsp; Die Binärfolge besteht aus&nbsp; $N = 1250$&nbsp; Binärsymbolen (ablesbar aus der letzten Spalte in der Tabelle).&nbsp; Damit benötigt man ohne Codierung ebenso viele Bit:  
+
'''(1)'''&nbsp; The binary sequence consists of&nbsp; $N = 1250$&nbsp; binary symbols&nbsp; (can be read from the last column in the table).&nbsp;  
:$$N_\text{Bit}\hspace{0.15cm}\underline{= 1250}.$$
+
*This means that the same number of bits is needed without coding:
 +
:$$N_\text{bits}\hspace{0.15cm}\underline{= 1250}.$$
  
  
'''(2)'''&nbsp; Die gesamte Symbolfolge der Länge&nbsp; $N = 1250$&nbsp; beinhaltet&nbsp; $N_{\rm B} =  25$&nbsp; Symbole&nbsp; ${\rm B}$&nbsp; und somit&nbsp; $N_{\rm A} =  1225$&nbsp; Symbole&nbsp; ${\rm A}$.&nbsp;
+
'''(2)'''&nbsp; The entire symbol sequence of length&nbsp; $N = 1250$&nbsp; contains&nbsp; $N_{\rm B} =  25$&nbsp; symbols&nbsp; ${\rm B}$&nbsp; and thus&nbsp; $N_{\rm A} =  1225$&nbsp; symbols&nbsp; ${\rm A}$.&nbsp;
*Die Anzahl&nbsp; $N_{\rm B}$&nbsp; der Symbole&nbsp; ${\rm B}$&nbsp; ist dabei gleich der Zeilenzahl in der vorne angegebenen Tabelle.   
+
*The number&nbsp; $N_{\rm B}$&nbsp; of symbols&nbsp; ${\rm B}$&nbsp; is equal to the number of rows in the table given at the front.   
*Damit gilt für die relative Häufigkeit&nbsp; von&nbsp; ${\rm B}$:
+
*Thus the following applies to the relative frequency of symbol&nbsp; ${\rm B}$:
 
:$$h_{\rm B} = \frac{N_{\rm B}}{N} = \frac{25}{1250} \hspace{0.15cm}\underline{= 0.02} = 2\%\hspace{0.05cm}. $$
 
:$$h_{\rm B} = \frac{N_{\rm B}}{N} = \frac{25}{1250} \hspace{0.15cm}\underline{= 0.02} = 2\%\hspace{0.05cm}. $$
  
  
'''(3)'''&nbsp; Wir betrachten nun&nbsp; <i>Run&ndash;Length Coding</i>&nbsp; $\rm (RLC)$, wobei jeder Abstand zwischen zwei&nbsp; ${\rm B}$&ndash;Symbolen mit acht Bit dargestellt wird&nbsp; $(D = 8)$.  
+
'''(3)'''&nbsp; We now consider&nbsp; "Run&ndash;Length Coding"&nbsp; $\rm (RLC)$, where each distance between two&nbsp; ${\rm B}$&ndash;symbols is represented by eight bits&nbsp; $(D = 8)$.  
*Damit ergibt sich mit&nbsp; $N_{\rm B} =  25$:
+
*Thus, with&nbsp; $N_{\rm B} =  25$, we get:
:$$N_{\rm Bit} = N_{\rm B} \cdot 8 \hspace{0.15cm}\underline{= 200} \hspace{0.05cm}.$$
+
:$$N_{\rm bits} = N_{\rm B} \cdot 8 \hspace{0.15cm}\underline{= 200} \hspace{0.05cm}.$$
  
  
'''(4)'''&nbsp; $\rm RLC$&nbsp;  mit&nbsp; $D = 7$&nbsp; erlaubt für&nbsp; $L_i$&nbsp; nur Werte zwischen&nbsp; $1$&nbsp; und&nbsp; $2^7-1 =127$.  
+
'''(4)'''&nbsp; $\rm RLC$&nbsp;  with&nbsp; $D = 7$&nbsp;only allows values between&nbsp; $1$&nbsp; und&nbsp; $2^7-1 =127$ for&nbsp; $L_i$.  
*Der Eintrag "226" in Zeile 19 ist aber größer &nbsp; &nbsp; &#8658; &nbsp; &nbsp; <u>NEIN</u>.
+
*However, the entry&nbsp; "226"&nbsp; in line 19 is greater &nbsp; &nbsp; &#8658; &nbsp; &nbsp; <u>NO</u>.
  
  
'''(5)'''&nbsp; Auch bei Run&ndash;Length Limited Coding&nbsp;  $\rm (RLLC)$&nbsp; sind für die "echten" Abstände&nbsp; $L_i$&nbsp; mit&nbsp; $D = 7$&nbsp; nur Werte bis&nbsp; $127$&nbsp; zulässig.  
+
'''(5)'''&nbsp; Even with Run&ndash;Length Limited Coding&nbsp;  $\rm (RLLC)$,&nbsp; only values up to&nbsp; $127$&nbsp; are permitted for the&nbsp; "real"&nbsp; distances&nbsp; $L_i$&nbsp; with&nbsp;  $D = 7$.
*Der Eintrag "226" in Zeile 19 wird bei&nbsp;  $\rm RLLC$&nbsp; ersetzt durch
+
*The entry&nbsp; "226"&nbsp; in line 19 is replaced by the following for&nbsp;  $\rm RLLC$:
  
:* Zeile 19a: &nbsp;  <b>S</b> = <b>0000000</b> &nbsp;&nbsp;&#8658;&nbsp;&nbsp; Sonderzeichen, steht für "+ 127",
+
:* Line 19a: &nbsp;  <b>S</b> = <b>0000000</b> &nbsp;&nbsp;&#8658;&nbsp;&nbsp; special character, stands for "+127",
  
:* Zeile 19b: &nbsp;  <b>1100011</b> &nbsp;&nbsp;&#8658;&nbsp;&nbsp; Dezimal 99.
+
:* Line 19b: &nbsp;  <b>1100011</b> &nbsp;&nbsp;&#8658;&nbsp;&nbsp; decimal 99.
  
*Damit erhält man insgesamt $26$ Worte zu je sieben Bit:
+
*This gives a total of $26$ words of seven bits each:
:$$N_{\rm Bit} = 26 \cdot 7 \hspace{0.15cm}\underline{= 182} \hspace{0.05cm}.$$
+
:$$N_{\rm bits} = 26 \cdot 7 \hspace{0.15cm}\underline{= 182} \hspace{0.05cm}.$$
  
  
'''(6)'''&nbsp; Nun müssen bei&nbsp; $\rm RLLC$&nbsp; gegenüber&nbsp; $\rm RLC$&nbsp; (siehe Tabelle) folgende Änderungen vorgenommen werden:
+
'''(6)'''&nbsp; With&nbsp;  $D = 6$&nbsp; the following changes have to be made in&nbsp; $\rm RLLC$&nbsp; compared to&nbsp; $\rm RLC$&nbsp; (see table):
  
* Zeile &nbsp;&nbsp;1: &nbsp; $122 = 1 &middot; 63 + 59$ &nbsp;&nbsp;(ein Wort mehr),
+
* Line &nbsp;&nbsp;1: &nbsp; $122 = 1 &middot; 63 + 59$ &nbsp;&nbsp;(one word more),
  
* Zeile &nbsp;&nbsp;6: &nbsp;&nbsp;&nbsp; $70 = 1 &middot; 63 + 7$ &nbsp;&nbsp;&nbsp;&nbsp;(ein Wort mehr),
+
* Line &nbsp;&nbsp;6: &nbsp;&nbsp;&nbsp; $70 = 1 &middot; 63 + 7$ &nbsp;&nbsp;&nbsp;&nbsp;(one word more),
  
* Zeile &nbsp;&nbsp;7: &nbsp;&nbsp;&nbsp; $80 = 1 &middot; 63 + 17$ &nbsp;&nbsp;(ein Wort mehr),
+
* Line &nbsp;&nbsp;7: &nbsp;&nbsp;&nbsp; $80 = 1 &middot; 63 + 17$ &nbsp;&nbsp;(one word more),
  
* Zeile 12: &nbsp;&nbsp;&nbsp; $79 = 1 &middot; 63 + 18$ &nbsp;&nbsp;(ein Wort mehr),
+
* Line 12: &nbsp;&nbsp;&nbsp; $79 = 1 &middot; 63 + 16$ &nbsp;&nbsp;(one word more),
  
* Zeile 13: &nbsp;&nbsp;&nbsp; $93 = 1 &middot; 63 + 30$ &nbsp;&nbsp;(ein Wort mehr),
+
* Line 13: &nbsp;&nbsp;&nbsp; $93 = 1 &middot; 63 + 30$ &nbsp;&nbsp;(one word more),
  
* Zeile 19: &nbsp; $226 = 3 &middot; 63 + 37$  &nbsp;&nbsp;(drei Worte mehr),
+
* Line 19: &nbsp; $226 = 3 &middot; 63 + 37$  &nbsp;&nbsp;(one word more),
  
* Zeile 25: &nbsp;&nbsp;&nbsp; $97 = 1 &middot; 63 + 34$  &nbsp;&nbsp;(ein Wort mehr).
+
* Line 25: &nbsp;&nbsp;&nbsp; $97 = 1 &middot; 63 + 34$  &nbsp;&nbsp;(one word more).
  
  
Damit erhält man insgesamt $34$ Worte zu je sechs Bit:
+
This gives a total of&nbsp; $25+9=34$&nbsp; words of six bits each:
:$$N_{\rm Bit} = 34 \cdot 6 \hspace{0.15cm}\underline{= 204} \hspace{0.05cm},$$
+
:$$N_{\rm bits} = 34 \cdot 6 \hspace{0.15cm}\underline{= 204} \hspace{0.05cm},$$
also ein schlechteres Ergebnis als mit sieben Bit gemäß Teilaufgabe '''(5)'''.
+
i.e. a worse result than with seven bits according to subtask '''(5)'''.
 
{{ML-Fuß}}
 
{{ML-Fuß}}
  

Latest revision as of 01:34, 13 November 2022

Table on Run-Length Coding

We consider a binary source with the symbol set  $\rm A$  and  $\rm B$, where  $\rm B$  however, occurs only very rarely.

  • Without source coding, exactly one bit would be needed per source symbol, and accordingly, for a source symbol sequence of length  $N$ , the encoded sequence would also have length   $N_\text{bits} = N$.
  • Entropy coding makes little sense here without further measures  (example:  combining several symbols into a tuple)  because of the unfavourable symbol probabilities.
  • The remedy is  Run-Length Coding  $(\rm RLC)$, which is described in the theory section under the link mentioned.  For example, for the symbol sequence   $\rm ABAABAAAABBAAB\text{...}$   the corresponding output of  "Run–Length Coding":   $ 2; \ 3; \ 5; \ 1; \ 3; \text{...}$
  • Of course, the lengths  $L_1 = 2$,  $L_2 = 3$, ...  of the individual substrings, each separated by  $\rm B$ , must be represented in binary before transmission.  If one uses  $D = 3$  (bit) for all  $L_i$  one obtains the RLC binary symbol sequence
$$010\hspace{0.05cm}\text{'}\hspace{0.05cm}011\hspace{0.05cm}\text{'}\hspace{0.05cm}101\hspace{0.05cm}\text{'}\hspace{0.05cm}001\hspace{0.05cm}\text{'}\hspace{0.05cm}011\hspace{0.05cm}\text{'}\hspace{0.05cm}\text{...}$$

The graph shows the RLC result to be analyzed.  Columns 2 and 3 show the substring lengths  $L_i$  in binary and decimal, respectively, and column 4 shows them in cumulative form  (values from column 3 added up).

  • One problem of  "Run-Length Coding"  $\rm (RLC)$ is the unlimited range of values of the quantities  $L_i$.  With  $D = 3$,  no value  $L_i > 7$  can be represented and with  $D = 2$,  the restriction is  $1 \le L_i \le 3$.
  • The problem is circumvented with  "Run–Length Limited Coding"  $\rm (RLLC)$.  If a value is  $L_i \ge 2^D$,  one replaces  $L_i$  with a special character  S  and the difference  $L_i - 2^D +1$.  With the RLLC decoder, this special character  S  is expanded again.





Hints:


$\text{RLLC Example}$:  We again assume the above sequence and the parameter  $D = 2$ :

  • Source symbol sequence:    $\rm ABAABAAAABBAAB$...
  • RLC decimal sequence:          2; 3; 5; 1; 3; ...
  • RLLC decimal sequence:       2;  3;  S; 2;  1;  3; ...
  • RLLC binary sequence:          10′11′ 00′10′01′11′...


You can see:

  • The special character  S  is binary-coded here as  00 .  This is only an example – it does not have to be like this.
  • Since with  $D = 2$  for all real RLC values  $1 \le L_i \le 3$ , the decoder recognizes the special character  00.
  • It replaces this again with  $2^D -1$  (three in the example)  $\rm A$–symbols.


Questions

1

How many bits would be needed  without source coding , i.e. with the assignment  $\rm A$   →  0  and  $\rm B$   →  1?

$N_\text{bits} \ = \ $

2

What is the relative frequency of symbol  $\rm B$?

$h_{\rm B}\ = \ $

$\ \%$

3

How many bits are needed for  Run–Length Coding  $\rm (RLC)$  according to the given table with eight bits per code word  $(D = 8)$?

$N_\text{bits} \ = \ $

4

Is  Run–Length Coding  with seven bit code words  $(D = 7)$  possible here?

Yes.
No.

5

How many bits are needed for  Run–Length Limited Coding  $\rm (RLLC)$  with seven bits per code word  $(D = 7)$?

$N_\text{bits} \ = \ $

6

How many bits are needed for  Run–Length Limited Coding  $\rm (RLLC)$  with six bits per code word  $(D = 6)$?

$N_\text{bits} \ = \ $


Solution

(1)  The binary sequence consists of  $N = 1250$  binary symbols  (can be read from the last column in the table). 

  • This means that the same number of bits is needed without coding:
$$N_\text{bits}\hspace{0.15cm}\underline{= 1250}.$$


(2)  The entire symbol sequence of length  $N = 1250$  contains  $N_{\rm B} = 25$  symbols  ${\rm B}$  and thus  $N_{\rm A} = 1225$  symbols  ${\rm A}$. 

  • The number  $N_{\rm B}$  of symbols  ${\rm B}$  is equal to the number of rows in the table given at the front.
  • Thus the following applies to the relative frequency of symbol  ${\rm B}$:
$$h_{\rm B} = \frac{N_{\rm B}}{N} = \frac{25}{1250} \hspace{0.15cm}\underline{= 0.02} = 2\%\hspace{0.05cm}. $$


(3)  We now consider  "Run–Length Coding"  $\rm (RLC)$, where each distance between two  ${\rm B}$–symbols is represented by eight bits  $(D = 8)$.

  • Thus, with  $N_{\rm B} = 25$, we get:
$$N_{\rm bits} = N_{\rm B} \cdot 8 \hspace{0.15cm}\underline{= 200} \hspace{0.05cm}.$$


(4)  $\rm RLC$  with  $D = 7$ only allows values between  $1$  und  $2^7-1 =127$ for  $L_i$.

  • However, the entry  "226"  in line 19 is greater     ⇒     NO.


(5)  Even with Run–Length Limited Coding  $\rm (RLLC)$,  only values up to  $127$  are permitted for the  "real"  distances  $L_i$  with  $D = 7$.

  • The entry  "226"  in line 19 is replaced by the following for  $\rm RLLC$:
  • Line 19a:   S = 0000000   ⇒   special character, stands for "+127",
  • Line 19b:   1100011   ⇒   decimal 99.
  • This gives a total of $26$ words of seven bits each:
$$N_{\rm bits} = 26 \cdot 7 \hspace{0.15cm}\underline{= 182} \hspace{0.05cm}.$$


(6)  With  $D = 6$  the following changes have to be made in  $\rm RLLC$  compared to  $\rm RLC$  (see table):

  • Line   1:   $122 = 1 · 63 + 59$   (one word more),
  • Line   6:     $70 = 1 · 63 + 7$     (one word more),
  • Line   7:     $80 = 1 · 63 + 17$   (one word more),
  • Line 12:     $79 = 1 · 63 + 16$   (one word more),
  • Line 13:     $93 = 1 · 63 + 30$   (one word more),
  • Line 19:   $226 = 3 · 63 + 37$   (one word more),
  • Line 25:     $97 = 1 · 63 + 34$   (one word more).


This gives a total of  $25+9=34$  words of six bits each:

$$N_{\rm bits} = 34 \cdot 6 \hspace{0.15cm}\underline{= 204} \hspace{0.05cm},$$

i.e. a worse result than with seven bits according to subtask (5).