Difference between revisions of "Exercise 2.13Z: Combination of BWT and MTF"

From LNTwww
Line 32: Line 32:
  
 
<quiz display=simple>
 
<quiz display=simple>
{Welche Aussagen gelten für den Block&nbsp; $\rm BWT$&nbsp; des Codiersystems?
+
{Which statements are true for block&nbsp; $\rm BWT$&nbsp; of the coding system?
 
|type="[]"}
 
|type="[]"}
+ Die Eingangszeichenmenge ist&nbsp; $\{ \hspace{0.05cm}\rm D,\hspace{0.05cm}  E,\hspace{0.05cm}  I,\hspace{0.05cm}  M,\hspace{0.05cm}  N , \hspace{0.05cm} S \}$.
+
+ The input character set is&nbsp; $\{ \hspace{0.05cm}\rm D,\hspace{0.05cm}  E,\hspace{0.05cm}  I,\hspace{0.05cm}  M,\hspace{0.05cm}  N , \hspace{0.05cm} S \}$.
+ Die Ausgangszeichenmenge ist $\{ \hspace{0.05cm}\rm D,\hspace{0.05cm}  E,\hspace{0.05cm}  I,\hspace{0.05cm}  M,\hspace{0.05cm}  N , \hspace{0.05cm} S \}$.
+
+ The output character set is $\{ \hspace{0.05cm}\rm D,\hspace{0.05cm}  E,\hspace{0.05cm}  I,\hspace{0.05cm}  M,\hspace{0.05cm}  N , \hspace{0.05cm} S \}$.
- In der Ausgangsfolge treten alle&nbsp; $M = 6$&nbsp; Zeichen gruppiert auf.
+
- In the output sequence, allnbsp; $M = 6$&nbsp; characters occur grouped together.
  
  
{Welche Aussagen gelten für den Block&nbsp; $\rm MTF$&nbsp; des Codiersystems?
+
{Which statements are true for the block&nbsp; $\rm MTF$&nbsp; of the coding system?
 
|type="[]"}
 
|type="[]"}
- Die Ausgangszeichenmenge ist&nbsp; $\{ \hspace{0.05cm}\rm D,\hspace{0.05cm}  E,\hspace{0.05cm}  I,\hspace{0.05cm}  M,\hspace{0.05cm}  N , \hspace{0.05cm} S \}$.
+
- The output character set is&nbsp; $\{ \hspace{0.05cm}\rm D,\hspace{0.05cm}  E,\hspace{0.05cm}  I,\hspace{0.05cm}  M,\hspace{0.05cm}  N , \hspace{0.05cm} S \}$.
+ Die Ausgangszeichenmenge ist&nbsp; $\{ \hspace{0.05cm}\rm 0,\hspace{0.05cm}  1,\hspace{0.05cm}  2,\hspace{0.05cm}  3,\hspace{0.05cm}  4 , \hspace{0.05cm} 5 \}$.
+
+ The output character set is&nbsp; $\{ \hspace{0.05cm}\rm 0,\hspace{0.05cm}  1,\hspace{0.05cm}  2,\hspace{0.05cm}  3,\hspace{0.05cm}  4 , \hspace{0.05cm} 5 \}$.
+ Die MTF&ndash;Ausgangsfolge hat die Länge&nbsp; $N = 12$.
+
+ The MTF output sequence has length&nbsp; $N = 12$.
  
  
{Wie lautet die&nbsp; $\rm MTF$&ndash;Ausgangsfolge?
+
{What is the&nbsp; $\rm MTF$ output sequence?
 
|type="()"}
 
|type="()"}
 
- $\rm 230000100405$,
 
- $\rm 230000100405$,
Line 53: Line 53:
  
  
{Welche Aussagen gelten für den Block&nbsp; $\rm RLC0$&nbsp; des Codiersystems?
+
{Which statements apply to block&nbsp; $\rm RLC0$&nbsp; of the coding system?
 
|type="[]"}
 
|type="[]"}
+ Der Eingangswert&nbsp;  $0$&nbsp; erfährt eine Sonderbehandlung.
+
+ The input value&nbsp;  $0$&nbsp; receives special treatment
+ Je häufiger eine&nbsp; $0$&nbsp; auftritt, um so effektiver ist dieser Block.
+
+ The more often a&nbsp; $0$&nbsp; occurs, the more effective this block is.
- Am besten wäre&nbsp; $\rm Pr(0) &asymp; Pr(1) &asymp; \text{...} &asymp; Pr(5)$.
+
- The best would be&nbsp; $\rm Pr(0) &asymp; Pr(1) &asymp; \text{...} &asymp; Pr(5)$.
  
  
{Welche Aussagen gelten für den abschließenden Block "Huffman"?
+
{Which statements are true for the final block "Huffman"?
 
|type="[]"}
 
|type="[]"}
+ Die Ausgangsfolge ist binär.
+
+ The initial sequence is binary.
+ Er bewirkt eine möglichst kleine mittlere Codewortlänge.
+
+ It causes the smallest possible average codeword length.
+ Die Dimensionierung richtet sich nach den anderen Blöcken.
+
+ The dimensioning depends on the other blocks.
  
  
Line 70: Line 70:
 
</quiz>
 
</quiz>
  
===Musterlösung===
+
===Solutions===
 
{{ML-Kopf}}
 
{{ML-Kopf}}
'''(1)'''&nbsp; Die Grafik auf der Angabenseite zeigt, dass die <u>Lösungsvorschläge 1 und 2</u> richtig sind und der Vorschlag 3 falsch ist:  
+
'''(1)'''&nbsp; The graph on the information page shows that <u>solution suggestions 1 and 2</u> are correct and suggestion 3 is incorrect:  
 
*$\rm E$&nbsp; und&nbsp; $\rm I$&nbsp; treten zwar gruppiert auf,  
 
*$\rm E$&nbsp; und&nbsp; $\rm I$&nbsp; treten zwar gruppiert auf,  
 
*aber nicht die&nbsp; $\rm N$&ndash;Zeichen.
 
*aber nicht die&nbsp; $\rm N$&ndash;Zeichen.
  
  
'''(2)'''&nbsp; Richtig sind die <u>Lösungsvorschläge 2 und 3</u>:  
+
'''(2)'''&nbsp;<u>Proposed solutions 2 and 3</u> are correct:  
*Die Eingangsfolge wird Zeichen für Zeichen abgearbeitet.&nbsp; Auch die Ausgangsfolge hat somit die Länge&nbsp; $N = 12$.
+
*The input sequence is processed character by character.&nbsp; Thus, the output sequence also has the length&nbsp; $N = 12$.
*Tatsächlich wird die Eingangsmenge&nbsp; $\{ \hspace{0.05cm}\rm D,\hspace{0.05cm}  E,\hspace{0.05cm}  I,\hspace{0.05cm}  M,\hspace{0.05cm}  N , \hspace{0.05cm} S \}$&nbsp; in die Ausgangsmenge&nbsp;  $\{ \hspace{0.05cm}\rm 0,\hspace{0.05cm}  1,\hspace{0.05cm}  2,\hspace{0.05cm}  3,\hspace{0.05cm}  4 , \hspace{0.05cm} 5 \}$&nbsp; gewandelt.  
+
*In fact, the input set&nbsp; $\{ \hspace{0.05cm}\rm D,\hspace{0.05cm}  E,\hspace{0.05cm}  I,\hspace{0.05cm}  M,\hspace{0.05cm}  N , \hspace{0.05cm} S \}$&nbsp; in die Ausgangsmenge&nbsp;  $\{ \hspace{0.05cm}\rm 0,\hspace{0.05cm}  1,\hspace{0.05cm}  2,\hspace{0.05cm}  3,\hspace{0.05cm}  4 , \hspace{0.05cm} 5 \}$&nbsp; is converted into the output set.  
*Allerdings nicht durch einfaches&nbsp; <i>Mapping</i>, sondern durch einen Algorithmus, der nachfolgend skizziert wird.
+
*However, not by simple&nbsp; <i>mapping</i>, but by an algorithm which is outlined below.
  
  
[[File:EN_Inf_Z_2_14.png|center|frame|Beispiel für den MTF–Algorithmus]]
+
[[File:EN_Inf_Z_2_14.png|center|frame|Example of the MTF algorithm]]
  
'''(3)'''&nbsp; Richtig ist der <u>Lösungsvorschlag 2</u>:
+
'''(3)'''&nbsp; Correct is <u>solution suggestion 2</u>:
*Die  Tabelle zeigt den MTF&ndash;Algorithmus.&nbsp; Der Schritt&nbsp; $i=0$&nbsp; (rote Hinterlegung) gibt die Vorbelegung an.&nbsp; Die Eingabe der MTF ist gelb hinterlegt, die Ausgabe grün.  
+
*The table shows the MTF algorithm.&nbsp; The step&nbsp; $i=0$&nbsp; (red background) indicates the preassignment.&nbsp; The input of the MTF is highlighted in yellow, the output in green.
* Im Schritt&nbsp; $i=1$&nbsp; wird das Eingangszeichen&nbsp; $\rm N$&nbsp; entsprechend der Spalte&nbsp; $i=0$&nbsp; durch den Index&nbsp; $I = 4$&nbsp; dargestellt.&nbsp; Anschließend wird&nbsp; $\rm N$&nbsp; nach vorne sortiert, während die Reihenfolge der anderen Zeichen gleich bleibt.
+
* In step&nbsp; $i=1$&nbsp;, the input character&nbsp; $\rm N$&nbsp; corresponding to column&nbsp; $i=0$&nbsp; is represented by index&nbsp; $I = 4$&nbsp;.&nbsp; Subsequently,&nbsp; $\rm N$&nbsp; is sorted to the front, while the order of the other characters remains the same.
* Das Eingangszeichen&nbsp; $\rm M$&nbsp; im zweiten Schritt erhält entsprechend der Spalte&nbsp; $i=2$&nbsp; ebenfalls den Index&nbsp; $I = 4$.&nbsp; In gleicher Weise macht man weiter bis zum zwölften Zeichen&nbsp; $\rm N$, dem der Index&nbsp; $I = 1$&nbsp; zugeordnet wird.
+
*The input character&nbsp; $\rm M$&nbsp; in the second step is also given the index&nbsp; $I = 4$ according to column&nbsp; $i=2$&nbsp;.&nbsp; One continues in the same way until the twelfth character&nbsp; $\rm N$, to which the index&nbsp; $I = 1$&nbsp; is assigned.
*Man erkennt aus obiger Tabelle weiter, dass zu den Zeitpunkten&nbsp; $i=6$,&nbsp; $i=7$,&nbsp; $i=10$&nbsp; und&nbsp; $i=11$&nbsp; der Ausgabeindex jeweils&nbsp; $I = 0$&nbsp; ist.
+
*You can see from the above table that at the times&nbsp; $i=6$,&nbsp; $i=7$,&nbsp; $i=10$&nbsp; and&nbsp; $i=11$&nbsp; the output index is&nbsp; $I = 0$&nbsp;.
  
  
  
'''(4)'''&nbsp; Richtig sind die <u>Aussagen 1 und 2</u>:  
+
'''(4)'''&nbsp; <u>Statements 1 and 2</u> are correct:  
*Die Vorverarbeitungen "BWT" und "MTF" haben nur die Aufgabe, möglichst viele Nullen zu generieren.
+
*The preprocessings "BWT" and "MTF" only have the task to generate as many zeros as possible.
  
  
  
'''(5)'''&nbsp; <u>Alle Aussagen</u> sind richtig.  
+
'''(5)'''&nbsp; <u>All statements</u> are correct.
*Nähere Angaben zum Huffman&ndash;Algorithmus finden Sie im Kapitel "Entropiecodierung nach Huffman".
+
*You can find more information on the Huffman algorithm in the chapter "Entropy coding according to Huffman".
 
{{ML-Fuß}}
 
{{ML-Fuß}}
  
  
 
[[Category:Information Theory: Exercises|^2.4 Further Source Coding Methods^]]
 
[[Category:Information Theory: Exercises|^2.4 Further Source Coding Methods^]]

Revision as of 21:17, 9 August 2021

Scheme for Burrows-Wheeler data compression

We refer to the theory page  Application Scenario for the Burrows-Wheeler Transform  and consider the coding system sketched on the right, consisting of the blocks.

  • Burrows–Wheeler–Transformation  $\rm (BWT)$  as described in  Exercise 2.13; the two character sets at the input and output of the BWT are the same:   $\{$ $\rm D$,  $\rm E$,  $\rm I$,  $\rm M$,  $\rm N$,  $\rm S$ $\}$;
  • Move–to–Front  $\rm (MTF)$, a sorting algorithm that outputs a string of the same length  $($  $N = 12 in the example)$, but with a different alphabet  $\{$012345$\}$ ;
  • $\rm RLC0$  – a run-length encoding specifically for zero, which is (as) frequent according to  $\rm BWT$  and  $\rm MTF$  ;  all other indices are not changed by  $\rm RLC0$ ;
  • $\rm Huffman$  as described in the chapter  Entropy coding according to Huffman; frequent characters are represented by short binary sequences and rare ones by long ones.


The  $\rm MTF$–algorithm can be described as follows for  $M = 6$  input symbols:

  • The output sequence of the  $\rm MTF$  is a string of indices from the set
       $ I = \{$012345$\}$.
  • Before starting the actual  $\rm MTF$ algorithm, the possible input symbols are sorted lexicographically and assigned to the following indices:
        $\rm D$   →   0,     $\rm E$   →   1,     $\rm I$   →   2,     $\rm M$   →   3,     $\rm N$   →   4,    $\rm S$   →   5.
  • Let the  $\rm MTF$ input string here be  $\rm N\hspace{0.05cm}M\hspace{0.05cm}S\hspace{0.05cm}D\hspace{0.05cm}E\hspace{0.05cm}E\hspace{0.05cm}E\hspace{0.05cm}N\hspace{0.05cm}I\hspace{0.05cm}I\hspace{0.05cm}I\hspace{0.05cm}N$.  This was the  $\rm BWT$ result in  Exercise 2.13.  The first  $\rm N$  is represented as  $I = 4$  according to the default setting.
  • Then the  $\rm N$  is placed at the beginning in the sorting, so that after the coding step  $i = 1$  the assignment holds:
        $\rm N$   →   0,     $\rm D$   →   1,     $\rm E$   →   2,     $\rm I$   →   3,     $\rm M$   →   4,    $\rm S$   →   5.
  • Continue in the same way until the entire input text has been processed.  If a character is already at position  0, no reordering is necessary.



Hints:

Questions

1

Which statements are true for block  $\rm BWT$  of the coding system?

The input character set is  $\{ \hspace{0.05cm}\rm D,\hspace{0.05cm} E,\hspace{0.05cm} I,\hspace{0.05cm} M,\hspace{0.05cm} N , \hspace{0.05cm} S \}$.
The output character set is $\{ \hspace{0.05cm}\rm D,\hspace{0.05cm} E,\hspace{0.05cm} I,\hspace{0.05cm} M,\hspace{0.05cm} N , \hspace{0.05cm} S \}$.
In the output sequence, allnbsp; $M = 6$  characters occur grouped together.

2

Which statements are true for the block  $\rm MTF$  of the coding system?

The output character set is  $\{ \hspace{0.05cm}\rm D,\hspace{0.05cm} E,\hspace{0.05cm} I,\hspace{0.05cm} M,\hspace{0.05cm} N , \hspace{0.05cm} S \}$.
The output character set is  $\{ \hspace{0.05cm}\rm 0,\hspace{0.05cm} 1,\hspace{0.05cm} 2,\hspace{0.05cm} 3,\hspace{0.05cm} 4 , \hspace{0.05cm} 5 \}$.
The MTF output sequence has length  $N = 12$.

3

What is the  $\rm MTF$ output sequence?

$\rm 230000100405$,
$\rm 445340045001$,
$\rm 543120345123$.

4

Which statements apply to block  $\rm RLC0$  of the coding system?

The input value  $0$  receives special treatment
The more often a  $0$  occurs, the more effective this block is.
The best would be  $\rm Pr(0) ≈ Pr(1) ≈ \text{...} ≈ Pr(5)$.

5

Which statements are true for the final block "Huffman"?

The initial sequence is binary.
It causes the smallest possible average codeword length.
The dimensioning depends on the other blocks.


Solutions

(1)  The graph on the information page shows that solution suggestions 1 and 2 are correct and suggestion 3 is incorrect:

  • $\rm E$  und  $\rm I$  treten zwar gruppiert auf,
  • aber nicht die  $\rm N$–Zeichen.


(2) Proposed solutions 2 and 3 are correct:

  • The input sequence is processed character by character.  Thus, the output sequence also has the length  $N = 12$.
  • In fact, the input set  $\{ \hspace{0.05cm}\rm D,\hspace{0.05cm} E,\hspace{0.05cm} I,\hspace{0.05cm} M,\hspace{0.05cm} N , \hspace{0.05cm} S \}$  in die Ausgangsmenge  $\{ \hspace{0.05cm}\rm 0,\hspace{0.05cm} 1,\hspace{0.05cm} 2,\hspace{0.05cm} 3,\hspace{0.05cm} 4 , \hspace{0.05cm} 5 \}$  is converted into the output set.
  • However, not by simple  mapping, but by an algorithm which is outlined below.


Example of the MTF algorithm

(3)  Correct is solution suggestion 2:

  • The table shows the MTF algorithm.  The step  $i=0$  (red background) indicates the preassignment.  The input of the MTF is highlighted in yellow, the output in green.
  • In step  $i=1$ , the input character  $\rm N$  corresponding to column  $i=0$  is represented by index  $I = 4$ .  Subsequently,  $\rm N$  is sorted to the front, while the order of the other characters remains the same.
  • The input character  $\rm M$  in the second step is also given the index  $I = 4$ according to column  $i=2$ .  One continues in the same way until the twelfth character  $\rm N$, to which the index  $I = 1$  is assigned.
  • You can see from the above table that at the times  $i=6$,  $i=7$,  $i=10$  and  $i=11$  the output index is  $I = 0$ .


(4)  Statements 1 and 2 are correct:

  • The preprocessings "BWT" and "MTF" only have the task to generate as many zeros as possible.


(5)  All statements are correct.

  • You can find more information on the Huffman algorithm in the chapter "Entropy coding according to Huffman".