Difference between revisions of "Coding teaser: source coding"

From Microlab Classes
Jump to navigation Jump to search
(Created page with "==Channel Capacity== ==Channel Rates== ==Source Coding== ==Huffman Coding==")
 
Line 1: Line 1:
 
==Channel Capacity==
 
==Channel Capacity==
 +
 +
{{Note| Make sure to read the [[Channeling_your_inner_capacity|Wiki page about the basics of a channel]]. Several discussions and interpretations are important for this chapter 😊.  |reminder}}
 +
 +
[[File:Bsc irs sweep.PNG|400px|thumb|right|Figure 1: <math> I(R,S) </math> of a BSC with varying <math> p </math> and parametrizing <math> \epsilon </math>.]]
 +
 +
Previously, we comprehensively investigated the measures of <math> H(R) </math>, <math>H(R|S) </math>, and <math> I(R,S) </math> on a BSC. Recall that:
 +
 +
 +
<math> I(R,S) = H(R) - H(R|S) </math>
 +
 +
 +
If you think about it, <math> I(R,S) </math> is a measure of channel quality. It tells us how much we can estimate the input from an observed output. In English, we said that <math> I(R,S) </math> is a measure of the received information contained in the source information. Ideally if there is no noise, then <math> H(R|S) = 0 </math> resulting in <math> I(R,S) = H(S) = H(R) </math>. We want this because this means all the information from the source gets to the receiver! When noise is present <math> H(R|S) \neq 0 </math>, it degrades the quality of our <math> I(R,S) </math> and the information about the receiver contained in the source is now being shared with noise. This only means one thing: ''' we want <math> I(R,S) </math> to be at maximum'''. From the previous discussion, we presented how <math> I(R,S) </math> varies with <math> p </math> and parametrizing the noise probability <math> \epsilon </math>. Figure 1 shows this plot (it's the same image from the last discussion). We can visualize <math> I(R,S) </math> like a pipe that constricts the flow of information depending on the noise parameter <math> \epsilon </math>. Figure 2 GIF shows the pipe visualization.
 +
 +
[[File:Pipe irs.gif|frame|center|Figure 2: Pipe visualization for <math> I(R,S) </math>]]
 +
 +
Let's modify our definition of <math> I(R,S) </math> a bit. In communication theory, <math> I(R,S) </math> is a metric for transmission rate. So the units is really in bits/second. Figure 1 demonstrates how much data can be transmitted per second. Interchanging between bits or bits/second might be confusing but for now, when we talk about channels (and also <math> I(R,S) </math>), let's use bits/s. Bits/s is also a measure of bandwidth. From the discussions, it is clear that we can define the '''maximum channel capacity''' <math> C </math> as:
 +
 +
{{NumBlk|::|<math> C = \max (I(S,R)) </math>|{{EquationRef|1}}}}
 +
 +
We can re-write this as:
 +
 +
{{NumBlk|::|<math> C = \max (H(R) - H(R|S)) </math>|{{EquationRef|1}}}}
 +
 +
Here, <math> C </math> is in units of bits/second. It tells us the maximum number of data that we can transmit per unit of time. Both <math> H(R) </math> and <math> H(R|S) </math> are affected by noise parameter <math> \epsilon </math>. In a way, noise limits <math> C </math>. For example, a certain <math> \epsilon </math> can only provide a certain maximum <math> I(R,S) </math>. Looking at figure 1, when <math> \epsilon = 0</math> (or <math> \epsilon = 1</math>) we can get a maximum <math> I(R,S) = 1</math> bits/s. When <math> \epsilon = 0.25</math> (or <math> \epsilon = 0.75 </math>) we can get a maximum <math>I(R,S) = 0.189 </math> bits/s. These occur when <math> p = 0.5 </math>. We can prove this mathematically. Let's determine <math> C </math> of a BSC given some <math> p </math> and <math> \epsilon </math>.
 +
 +
<math> C = \max ( H(R) - H(R|S)) </math>
 +
 +
Since we know <math> H(R) </math> follows the Bernoulli entropy <math> H_b(q) </math> where <math> q = p + \epsilon - 2\epsilon p </math>. Then we can just write:
 +
 +
<math> H(R) = H_b(q) = -q \log_2(q) - (1-q) \log_2 (1-q) </math>
 +
 +
<math> \max(H(R)) = 1 </math> bits when <math> q = 0.5 </math>. Since <math> \epsilon </math> is fixed depending on the channel, we can manipulate the input probability <math> p </math> such that we can force <math> q = 0.5</math> and achieve the maximum <math> H(R) </math>. Hold on to this very important thought. We also know that <math> H(R|S) = H_b(\epsilon) </math>. Unfortunately, since <math> \epsilon </math> is fixed then we can't immediately assume <math> H_b(\epsilon) = 1</math> not unless <math> \epsilon = 0.5 </math>. Therefore we can write <math> C </math> as:
 +
 +
<math> C = \max ( H_b(q) - H_b(\epsilon)) </math>
 +
 +
Leading to:
 +
 +
{{NumBlk|::|<math> C = 1 - H_b(\epsilon) </math>|{{EquationRef|2}}}}
 +
 +
Equation 2 shows how the maximum capacity is limited by the noise <math> \epsilon </math>. It describes the pipe visualization in figure 1. When <math> \epsilon = 0</math>, <math> H_b(\epsilon) = 0 </math> and our BSC can transmit <math> C = 1.0 </math> bits/s of data. When <math> \epsilon = 0.5 </math>, <math> H_b(\epsilon) = 1 </math>, the noise entropy is at maximum and our channel can transmit <math> C = 0 </math> bits/s. Clearly, we can't transmit data this way. Lastly, when <math> \epsilon = 1 </math>, then <math> H_b(\epsilon) = 0 </math> again and we're back to transmitting <math> C = 1</math> bits/s.
 +
 +
Again, we can assume <math> \max (H_b(q)) = 1 </math> because we can transform the input to have a new probability distribution <math> p </math> that maximizes <math> H_b(q) </math>! If we have the In fact, this is a prelude Shannon's source coding theorem:
 +
 +
 +
'' "Let a source have entropy <math> H </math> (bits per symbol) and a channel have a capacity <math> C </math> (bits per second). Then it is possible to encode the output of the source in such a way as to transmit at the average rate <math> C/H - \epsilon </math> symbols per second over the channel where <math> \epsilon </math> is arbitrarily small. It is not possible to transmit at an average rate greater than <math> C/H </math>." '' <ref> Shannon, C. E., & Weaver, W. (1949). The mathematical theory of communication. Urbana: University of Illinois Press. </ref>
 +
 +
 +
Note that the above statement only says that we can recode the source into something that can maximize the channel capacity. Also note that the <math> \epsilon </math> is an arbitrary error. Not the noise probability. Figure 1 and our idea
 +
<math> </math>
  
 
==Channel Rates==
 
==Channel Rates==

Revision as of 11:23, 1 March 2022

Channel Capacity

Make sure to read the Wiki page about the basics of a channel. Several discussions and interpretations are important for this chapter 😊.
Figure 1: of a BSC with varying and parametrizing .

Previously, we comprehensively investigated the measures of , , and on a BSC. Recall that:



If you think about it, is a measure of channel quality. It tells us how much we can estimate the input from an observed output. In English, we said that is a measure of the received information contained in the source information. Ideally if there is no noise, then resulting in . We want this because this means all the information from the source gets to the receiver! When noise is present , it degrades the quality of our and the information about the receiver contained in the source is now being shared with noise. This only means one thing: we want to be at maximum. From the previous discussion, we presented how varies with and parametrizing the noise probability . Figure 1 shows this plot (it's the same image from the last discussion). We can visualize like a pipe that constricts the flow of information depending on the noise parameter . Figure 2 GIF shows the pipe visualization.

Figure 2: Pipe visualization for

Let's modify our definition of a bit. In communication theory, is a metric for transmission rate. So the units is really in bits/second. Figure 1 demonstrates how much data can be transmitted per second. Interchanging between bits or bits/second might be confusing but for now, when we talk about channels (and also ), let's use bits/s. Bits/s is also a measure of bandwidth. From the discussions, it is clear that we can define the maximum channel capacity as:

 

 

 

 

(1)

We can re-write this as:

 

 

 

 

(1)

Here, is in units of bits/second. It tells us the maximum number of data that we can transmit per unit of time. Both and are affected by noise parameter . In a way, noise limits . For example, a certain can only provide a certain maximum . Looking at figure 1, when (or ) we can get a maximum bits/s. When (or ) we can get a maximum bits/s. These occur when . We can prove this mathematically. Let's determine of a BSC given some and .

Since we know follows the Bernoulli entropy where . Then we can just write:

bits when . Since is fixed depending on the channel, we can manipulate the input probability such that we can force and achieve the maximum . Hold on to this very important thought. We also know that . Unfortunately, since is fixed then we can't immediately assume not unless . Therefore we can write as:

Leading to:

 

 

 

 

(2)

Equation 2 shows how the maximum capacity is limited by the noise . It describes the pipe visualization in figure 1. When , and our BSC can transmit bits/s of data. When , , the noise entropy is at maximum and our channel can transmit bits/s. Clearly, we can't transmit data this way. Lastly, when , then again and we're back to transmitting bits/s.

Again, we can assume because we can transform the input to have a new probability distribution that maximizes ! If we have the In fact, this is a prelude Shannon's source coding theorem:


"Let a source have entropy (bits per symbol) and a channel have a capacity (bits per second). Then it is possible to encode the output of the source in such a way as to transmit at the average rate symbols per second over the channel where is arbitrarily small. It is not possible to transmit at an average rate greater than ." [1]


Note that the above statement only says that we can recode the source into something that can maximize the channel capacity. Also note that the is an arbitrary error. Not the noise probability. Figure 1 and our idea


Channel Rates

Source Coding

Huffman Coding

  1. Shannon, C. E., & Weaver, W. (1949). The mathematical theory of communication. Urbana: University of Illinois Press.