2014年2月22日星期六

Week 4

This week, we have finish implementing the Huffman encoder and the decoder.

Demonstration of the encoder:

This is the function used to test the encoder:


After running the code, the result is showed below:
In this case, the coding efficiency is 100%(entropy/average length*100%), which is really high. However, in practical situation, the efficiency is not possible to reach 100%.


This is the sequence need to be encode.


The dictionary was established by the function wrote last week.


The output code is shown in the following chart:





The encoded sequence will be transmitted through channel. At the receiver end, the code will be received and should be decoded according to the dictionary.

Following is a test of the decoder:

Add the decoder.
Since the actualsig is generated randomly, hence, when running the code again, the actualsig will be different from the previous encode one. Here we involved 'isequal' function. We only need to make sure that the code before encode and after decode are same. 'isequal' will return 1 if decode and actualsig are same. 
After running the program, it returns 1, which means this function works.


没有评论:

发表评论