Difference between revisions of "161-A2.1"

From Microlab Classes
Jump to navigation Jump to search
Line 9: Line 9:
  
 
{{NumBlk|::|<math>H\left(S\right) = 0.5\log_2\left(\frac{1}{0.5}\right) + 0.25\log_2\left(\frac{1}{0.25}\right) + 0.125\log_2\left(\frac{1}{0.125}\right) + 0.125\log_2\left(\frac{1}{0.125}\right) = 1.75\,\mathrm{bits}</math>|{{EquationRef|1}}}}
 
{{NumBlk|::|<math>H\left(S\right) = 0.5\log_2\left(\frac{1}{0.5}\right) + 0.25\log_2\left(\frac{1}{0.25}\right) + 0.125\log_2\left(\frac{1}{0.125}\right) + 0.125\log_2\left(\frac{1}{0.125}\right) = 1.75\,\mathrm{bits}</math>|{{EquationRef|1}}}}
 +
 +
Let us look at a few bit sequence assignments and see if they are uniquely decodable or not.
 +
 +
{| class = "wikitable"
 +
! Symbol
 +
! Probability
 +
! Code 1
 +
! Code 2
 +
! Code 3
 +
! Code 4
 +
! Code 5
 +
|-
 +
| <math>a_1</math>
 +
| 0.5
 +
| 0
 +
| 0
 +
| 0
 +
| 0
 +
| 00
 +
|-
 +
| <math>a_2</math>
 +
| 0.25
 +
| 0
 +
| 1
 +
| 10
 +
| 01
 +
| 01
 +
|-
 +
| <math>a_3</math>
 +
| 0.125
 +
| 1
 +
| 00
 +
| 110
 +
| 011
 +
| 10
 +
|-
 +
| <math>a_4</math>
 +
| 0.125
 +
| 10
 +
| 11
 +
| 111
 +
| 0111
 +
| 11
 +
|-
 +
| colspan="2"|Average Code Length
 +
|
 +
|
 +
|
 +
|
 +
|
 +
|-
 +
|}

Revision as of 19:55, 17 September 2020

  • Activity: Source Coding
  • Instructions: In this activity, you are tasked to
    • Walk through the examples.
    • Write a short program to compress and decompress a redundant file.
  • Should you have any questions, clarifications, or issues, please contact your instructor as soon as possible.

Uniquely Decodable Codes

Let us try to encode a source with just four symbols in its alphabet, i.e. , with probability distribution . We can calculate the entropy of this source as:

 

 

 

 

(1)

Let us look at a few bit sequence assignments and see if they are uniquely decodable or not.

Symbol Probability Code 1 Code 2 Code 3 Code 4 Code 5
0.5 0 0 0 0 00
0.25 0 1 10 01 01
0.125 1 00 110 011 10
0.125 10 11 111 0111 11
Average Code Length