7 Pages

hw5sol

Course: EE 376A, Fall 2011
School: Stanford
Rating:
 
 
 
 
 

Word Count: 1338

Document Preview

376A/Stat EE 376A Information Theory Prof. T. Cover Handout #17 Tuesday, February 15, 2011 Solutions to Homework Set #5 1. Bad codes. Which of these codes cannot be Huffman codes for any probability assignment? (a) {1, 01, 00}. (b) {00, 01, 10, 110}. (c) {01, 10}. Solution: Bad codes. (a) {1,01,00} is a Huffman code for the distribution ( 1 , 1 , 1 ). 2 4 4 (b) The code {00,01,10, 110} can be shortened to...

Register Now

Unformatted Document Excerpt

Coursehero >> California >> Stanford >> EE 376A

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
376A/Stat EE 376A Information Theory Prof. T. Cover Handout #17 Tuesday, February 15, 2011 Solutions to Homework Set #5 1. Bad codes. Which of these codes cannot be Huffman codes for any probability assignment? (a) {1, 01, 00}. (b) {00, 01, 10, 110}. (c) {01, 10}. Solution: Bad codes. (a) {1,01,00} is a Huffman code for the distribution ( 1 , 1 , 1 ). 2 4 4 (b) The code {00,01,10, 110} can be shortened to {00,01,10, 11} without losing its instantaneous property, and therefore is not optimal, so it cannot be a Huffman code. Alternatively, it is not a Huffman code because there is a unique longest codeword. (c) The code {01,10} can be shortened to {0,1} without losing its instantaneous property, and therefore is not optimal and not a Huffman code. 2. Huffman coding. Consider the random variable ( ) x1 x2 x3 x4 x5 x6 x7 X= 0.50 0.26 0.11 0.04 0.04 0.03 0.02 (a) Find a binary Huffman code for X. (b) Find the expected codelength for this encoding. (c) Find a ternary Huffman code for X. Solution: Huffman coding. 1 (a) The Huffman tree for this distribution is Codeword 1 x1 0.50 0.50 0.50 0.50 01 x2 0.26 0.26 0.26 0.26 001 x3 0.11 0.11 0.11 0.11 00011 x4 0.04 0.04 0.08 0.13 00010 x5 0.04 0.04 0.05 00001 x6 0.03 0.05 00000 x7 0.02 0.50 0.26 0.24 0.50 0.50 1 (b) The expected length of the codewords for the binary Huffman code is 2 bits. (H(X) = 1.99 bits) (c) The ternary Huffman tree is Codeword 0 x1 0.50 0.50 0.50 1.0 1 x2 0.26 0.26 0.26 20 x3 0.11 0.11 0.24 21 x4 0.04 0.04 222 x5 0.04 0.09 221 x6 0.03 220 x7 0.02 This code has an expected length 1.33 ternary symbols. (H3 (X) = 1.25 ternary symbols). 3. Codes. Let X1 , X2 , . . . , i.i.d. with 1, 2, X= 3, with probability 1/2 with probability 1/4 with probability 1/4. Consider the code assignment 0, 01, C(x) = 11, if x = 1 if x = 2 if x = 3. (a) Is this code nonsingular? (b) Uniquely decodable? (c) Instantaneous? (d) What is the entropy rate of the process Z1 Z2 Z3 . . . = C(X1 )C(X2 )C(X3 ) . . .? 2 For example, xn = 2311 . . . gives the encoded process z n = 011100 . . . . Solution: Codes. (a) Yes, this code is nonsingular because C(x) is different for every x. (b) Yes, this code is uniquely decodable. Reversing the codewords if x = 1 0, 10, if x = 2 C (x) = 11, if x = 3 gives an instantaneous code, and thus a uniquely decodable code. Therefore the reversed extension is uniquely decodable, and so the extension itself is also uniquely decodable. (c) No, this code is not instantaneous because C(1) is a prefix of C(2). (d) The expected codeword length is 3 L(C(x)) = 0.5 1 + 0.25 2 + 0.25 2 = . 2 Further, the entropy rate of the i.i.d. X n is 3 H(X ) = H(X) = H(.5, .25, .25) = . 2 So the code is a uniquely decodable code with L = H(X ), and therefore the sequence is maximally compressed with H(Z) = 1 bit. If H(Z) were less than its maximum of 1 bit then the Z n sequence could be further compressed to its entropy rate, and X m could also be compressed further by blockcoding. However, this would result in Lm < H(X ) which contradicts theorem 5.4.2 of the text. So H(Z) = 1 bit. Note that the Z n sequence is not i.i.d. Br( 1 ), even though H(Z) = 1 bit. For 2 1 example, P {Z1 = 1} = 4 , and a sequence starting 10 . . . is not allowed. However, once Zi = 0 for some i then Zk is Bernoulli( 1 ) for k > i, so Z n is asymptotically 2 Bernoulli( 1 ) and gives the entropy rate of 1 bit. 2 4. Bad wine. One is given 6 bottles of wine. It is known that precisely one bottle has gone bad (tastes terrible). From inspection of the bottles it is determined that the probability 7 5 4 4 3 3 pi that the ith bottle is bad is given by (p1 , p2 , . . . , p6 ) = ( 26 , 26 , 26 , 26 , 26 , 26 ). Tasting will determine the bad wine. 3 Suppose you taste the wines one at a time. Choose the order of tasting to minimize the expected number of tastings required to determine the bad bottle. Remember, if the first 5 wines pass the test you don't have to taste the last. (a) What is the expected number of tastings required? (b) Which bottle should be tasted first? Now you get smart. For the first sample, you mix some of the wines in a fresh glass and sample the mixture. You proceed, mixing and tasting, stopping when the bad bottle been has determined. (c) What is the minimum expected number of tastings required to determine the bad wine? (d) What mixture should be tasted first? Solution: Bad wine. (a) If we taste one bottle at a time, the corresponding number of tastings are {1, 2, 3, 4, 5, 5} with some order. By the same argument as in Lemma 5.8.1, to minimize the ex pected length pi lk we should have lj lk if pj > pk . Hence, the best order of tasting should be from the most likely wine to be bad to the least. The expected number of tastings required is 6 i=1 p i li = 1 75 26 = 2.88 = 7 5 4 4 3 3 +2 +3 +4 +5 +5 26 26 26 26 26 26 (b) The first bottle to be tasted should be the one with probability (c) The idea is to use Huffman coding. 7 . 26 (01) (11) (000) (001) (100) (101) 7 5 4 4 3 3 7 6 5 4 4 8 7 6 5 11 8 7 15 11 26 4 The expected number of tastings required is 6 i=1 p i li = 2 66 26 = 2.54 = 7 5 4 4 3 3 +2 +3 +3 +3 +3 26 26 26 26 26 26 Note that H(p) = 2.52 bits. (d) The mixture of the first, third, and forth bottles should be tasted first, (or equivalently the mixture of the second, fifth and sixth). 5. Minimum cost codes. Words like Run! Help! and Fire! are short, not because they are frequently used, but perhaps because time is precious in the situations in which these words are required. Suppose that X = i with probability pi , i = 1, 2, . . . , m. Let li be the number of binary symbols in the codeword associated with X = i, and let ci denote the cost per letter of the codeword when X = i. Thus the average cost C of the description of X is C = m pi ci li . i=1 -li (a) Minimize C over all l1 , l2 , . . . , lm such that 2 1. Ignore any implied integer constraints on li . Exhibit the minimizing l1 , l2 , . . . , lm and the associated minimum value C . (b) How would you use the Huffman code procedure to minimize C over all uniquely decodable codes? Let CHuffman denote this minimum. (c) Show that C CHuffman C + Minimum cost codes. -ni (a) We wish to minimize C = pi ci ni subject to 2 1. We will assume equality in the constraint and let ri = 2-ni and let Q = i pi ci . Let qi = (pi ci )/Q. Then q also forms a probability distribution and we can write C as C = pi ci ni (1) 1 = Q qi log (2) ri ( ) qi = Q qi log - qi log qi (3) ri = Q(D(q||r) + H(q)). (4) 5 m i=1 pi ci . Since the only freedom is in the choice of ri , we can minimize C by choosing r = q or pi ci n = - log , (5) i pj cj where we have ignored any integer constraints on ni . The minimum cost C for this assignment of codewords is C = QH(q) (6) (b) If we use q instead of p for the Huffman procedure, we obtain a code minimizing expected cost. (c) Now we can account for the integer constraints. Let ni = - log qi Then - log qi ni < - log qi + 1 Multiplying by pi ci and summing over i, we get the relationship C CHuf f man < C + Q. (9) (8) (7) 6. Relative entropy is cost of miscoding. Let the random variable X have five possible outcomes {1, 2, 3, 4, 5}. Consider two distributions on this random variable Symbol p(x) q(x) C1 (x) C2 (x) 1 1/2 1/2 0 0 2 1/4 1/8 10 100 3 1/8 1/8 110 101 4 1/16 1/8 1110 110 5 1/16 1/8 1111 111 (a) Calculate H(p), H(q), D(p||q) and D(q||p). (b) The last two columns above represent codes for the random variable. Verify that the average length of C1 under p is equal to the entropy H(p). Thus C1 is optimal for p. Verify that C2 is optimal for q. (c) Now assume that we use code C2 when the distribution is p. What is the average length of the codewords. By how much does it exceed the entropy H(p)? (d) What is the loss if we use code C1 when the distribution is q? Solution: Relative entropy is cost of miscoding. 6 (a) H(p) = i -pi log pi 1 1 1 1 1 1 1 1 = - log - log - log - 2 log 2 2 4 4 8 8 16 16 15 = . 8 Similarly, H(q) = 2. D(p||q) = i pi log pi qi 1 1/2 1 1/4 1 1/8 1 1/16 = log + log + log +2 log 2 1/2 4 1/8 8 1/8 16 1/8 1 = . 8 1 Similarly, D(q||p) = 8 . (b) The average codeword length for C1 is EL1 = 1 1 1 1 15 1+ 2+ 3+2 4= . 2 4 8 16 8 Similarly, the average codeword length for C2 is 2. (c) 1 1 1 1 1+ 3+ 3+2 3 = 2, 2 4 8 16 1 which exceeds H(p) by D(p||q) = 8 . Ep L2 = (d) Similarly, Eq L1 = 17 , 8 1 which exceeds H(q) by D(q||p) = 8 . 7
Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Stanford - EE - 376A
EE 376A Information Theory Prof. T. CoverHandout #21 Tuesday, March 1, 2011Solutions to Homework Set #6 1. Postprocessing the output. One is given a communication channel with transition probabilities p(y | x) and channel capacity C = max I(X; Y ). A he
Stanford - EE - 376A
EE 376A Information Theory Prof. T. CoverHandout #24 Thursday, March 10, 2011Solutions to Homework Set #71. Source and channel. We wish to encode a Bernoulli() process V1 , V2 , . . . for transmission over a binary symmetric channel with error probabil
Ohio State - MATH - 255
Midterm 2 of Math 255.01 (Wi11)February 25, 2011 1:30pm-2:18pm The Ohio State UniversityIncluding the cover sheer, this exam consists of five (5) pages and four (4) problems and is worth a total of 100 points. The point value of each problem is indicate
Ohio State - MATH - 255
Midterm 1 of Math 255.01 (Wi11)January 28, 2011 1:30pm-2:18pm The Ohio State UniversityIncluding the cover sheer, this exam consists of five (5) pages and four (4) problems and is worth a total of 100 points. The point value of each problem is indicated
Ohio State - MATH - 255
SYLLABUS FOR MATH 255 (This syllabus will be updated and adjusted to reflect the pace of the course; please check it regularly.) Purpose of the course The course is an introduction to the most basic concepts and methods in solving ordinary differential eq
Ohio State - MATH - 255
Ohio State - MATH - 255
Ohio State - MATH - 255
Ohio State - MATH - 255
Ohio State - MATH - 255
Virginia Tech - ME - 2024
Memorandum Guidelines1. Memoranda (memo's) should be on company stationery, if a paper memo. 2. memo's should be concise. 3. Introduce the topic quickly. Provide only the necessary detail to enable the reader to make a decision or follow the instructions
Virginia Tech - ME - 2024
ME2024: Engineering Design and Economics (W2D2) As you walk-in:Log on to the ME 2024 Scholar site. There is a Quiz awaiting you!Day 1 Week 2 at a GlanceGeneric Product Development Exercise Objective: Walk through the Product Development Phases Writte
Virginia Tech - ME - 2024
ME 2024 Engineering Design and Economics Seven Things You Should Not Write in a Memo Filler terms, offensive phrases, and more . . .Simply: Simply, you are going to offend someone. Obviously: Obviously you are going to offend someone. Essentially: Essent
Virginia Tech - ME - 2024
ME2024: Engineering Design and Economics (W2D3) As you walk-in:Log on to the ME 2024 Scholar site. Quiz 4 is due by Monday! Open Dissection 2 Exercise.Day 1 Week 2 at a GlanceGeneric Product Development Exercise Objective: Walk through the Product De
Virginia Tech - ME - 2024
ElecNose Business Plan ElecNose is developing a chemical analyzer and sensor cartridge, based upon Electronic Nose technology, which can instantly analyze complex chemical compounds.Figure 1. Electronic Nose Sensor. Numerous applications need real-time,
Virginia Tech - ME - 2024
ME2024: Engineering Design and Economics (W3D1) As you walk-in:Log on to the ME 2024 Scholar site.Download materials from W3D1 Quiz 5 awaits you! Project Proposals (10 min.)Discuss each person's proposal &amp; submit best one to Scholar by the end of cla
UGA - GENE - 3200
Common Sense (1776) Thomas Paine, originally from Britain Moved independence issue to center stage It had not been considered seriously early on. Within three months 120,000 copies had been sold. Endorsement of Republican Democracy as an alternative to mo
UGA - GENE - 3200
GENE3200 Summer 2010 Bedell Exam 3 July 15 810 no._KEY_Write your ID number (810 number, NOT SSN) on every page. Write your initials on the first page only. All of the multiple choice questions have only one correct answer. The exam should be completed
UGA - GENE - 3200
GENE 3200 Summer 2010 Bedell Exam 4 July 26 vA (no asterisk) ID no. 810_KEY_Write your ID number (810 number, NOT SSN) on every page. Write your initials on the first page only. All of the multiple choice questions have only one correct answer. The exa
UGA - GENE - 3200
GENE 3200 Summer 2010 Bedell Final exam July 30 ID no. 810_KEY_Write your ID number (810 number, NOT SSN) on every page. Write your initials on the first page only. All of the multiple choice questions have only one correct answer. The exam should be c
UGA - CHEM - 2211
UGA - CHEM - 2211
UGA - CHEM - 2211
Abstract This study evaluated the effect of 48 hour sleep deprivation on sleep deprived and non sleep deprived college students. It is a between subject, factorial experiment. The participants were tested on their executive functioning and memory performa
UGA - CHEM - 2211
Michele Chan Annotated bibliography: Sleep deprivation on memory functions Jian-Lin, Q., Yong-Cong, S., Danmin, M., Ming, F., Guo-Hua, B., &amp; Zheng, Y. (2010). The Effects Of 43 Hours Of Sleep Deprivation On Executive Control Functions: Event-Related Poten
UGA - CHEM - 2211
UGA - CHEM - 2211
CHEM 2212L Experiment #3 Friedel-Crafts Post Lab Questions1. Provide structures for the major, disubstitution Friedel-Crafts product(s) of the following reactions:2. Provide a detailed mechanism for the Friedel-Crafts alkylation reaction provided below.
UGA - SPCM - 3700
COMM 3700: Study Questions The definition of a constant- something that remains the same 3 reasons why hypotheses are important: 1. The way that you phrase hypothesis will directly affect how you conduct your study. 2. Will directly affect what you think
UGA - SPCM - 3700
COMM 3700: Study Questions How to assess the validity of survey measures measurement validity: one of four criteria by which the trustworthiness of quantitative research is evaluated. Refers to a measure that accurately reflects the concept it is intended
UGA - SPCM - 3700
COMM 3700: Study Questions The definitions of and distinction between the theoretical (or target) population and the accessible population Theoretical- everyone you're interested in studying; sometimes and sometimes not accessible Accessible- population y
UGA - SPCM - 3700
COMM 3700: Study Questions The definition of research The search for knowledge, any systematic investigation to establish facts, solve new or existing problems, prove new ideas or develop new theories, usually using a scientific method The definitions of
UGA - GENE - 3200
Clinton on Romney Romney is a conservative. He is a flip-flopper, as his position is constantly changing. He compromises his own beliefs for what he believes is expected. Changing stance on abortion Lack of personal tax exemption for failure to acquire he
UGA - GENE - 3200
GENE 3200 Fall 2010 Bedell Exam 1 Sept 9 ID no. 810_Write your ID number (810 number, NOT SSN) on every page. Write your initials on the first page only. All of the multiple choice questions have only one correct answer. The exam should be completed in
UGA - GENE - 3200
GENE 3200 Fall 2010 Bedell Exam 1 Sept 9 ID no. 810_KEY_Write your ID number (810 number, NOT SSN) on every page. Write your initials on the first page only. All of the multiple choice questions have only one correct answer. The exam should be completed
UGA - GENE - 3200
GENE 3200 Summer 2010 Exam 2 Bedell July 1ID no. 810_KEY_Write your ID number (810 number, NOT SSN) on every page. Write your initials on the first page only. All of the multiple choice questions have only one correct answer. The exam should be complete
UGA - GENE - 3200
GENE 3200 Fall 2010 Bedell Exam 2 Oct 7 ID no. 810_Write your ID number (810 number, NOT SSN) on every page. Write your initials on the first page only. All of the multiple choice questions have only one correct answer. The exam should be completed in i
UGA - GENE - 3200
GENE 3200 Fall 2010 Bedell Exam 2 Oct 7 ID no. 810_KEY_Write your ID number (810 number, NOT SSN) on every page. Write your initials on the first page only. All of the multiple choice questions have only one correct answer. The exam should be completed
UGA - GENE - 3200
GENE3200 Fall 2010 Bedell Exam 4 Dec 2 ID no. 810 _Write your ID number (810 number, NOT SSN) on every page. Write your initials on the first page only. All of the multiple choice questions have only one correct answer. The exam should be completed in i
UGA - GENE - 3200
GENE3200 Fall 2010 Bedell Exam 4 Dec 2 ID no. 810 _KEY_Write your ID number (810 number, NOT SSN) on every page. Write your initials on the first page only. All of the multiple choice questions have only one correct answer. The exam should be completed
UGA - GENE - 3200
GENE3200 Fall 2010 Bedell Final Exam Dec 9 ID no. 810 _KEY_Write your ID number (810 number, NOT SSN) on every page. Write your initials on the first page only. All of the multiple choice questions have only one correct answer.1. In humans there are th
UGA - GENE - 3200
GENE3200 Fall 2010 Bedell Final Exam Dec 9 ID no. 810 _Write your ID number (810 number, NOT SSN) on every page. Write your initials on the first page only. All of the multiple choice questions have only one correct answer.1. In humans there are three
UGA - GENE - 3200
Discussion: The hypothesis for this experiment was supported as the chronically sleep deprived student maintain executive control after an all nighter and performed well in a memory test. From the results, looking at executive function, all of the test gr
UGA - GENE - 3200
GENE 3200 Summer 2009 Bedell Exam 1 June 17 ID no. 810_Corrected KEY 9/14/09_Write your ID number (810 number, NOT SSN) on every page. Write your initials on the first page only. All of the multiple choice questions have only one correct answer. The ex
UGA - GENE - 3200
GENE 3200 Summer 2009 Bedell Exam 2 June 29 ID no. 810_FINAL KEY_Write your ID number (810 number, NOT SSN) on every page. Write your initials on the first page only. All of the multiple choice questions have only one correct answer. The exam should be
UGA - GENE - 3200
GENE 3200 Summer 2009 Bedell Exam 3 July 9 ID no. 810_KEY_Write your ID number (810 number, NOT SSN) on every page. Write your initials on the first page only. All of the multiple choice questions have only one correct answer. The exam should be complet
UGA - GENE - 3200
GENE 3200 Summer 2009 Bedell Exam 4 July 20 ID no. 810_KEY_Write your ID number (810 number, NOT SSN) on every page. Write your initials on the first page only. All of the multiple choice questions have only one correct answer. The exam should be comple
UGA - GENE - 3200
Federal System oPolitical system created in the U.S. Constitution in which power is divided between the national government and the state governments and in which independent states are bound together under one national government oExample; oNational gove
UGA - GENE - 3200
GENE 3200 Summer 2009 Bedell Cumulative Final July 31 ID no. 810_KEY_Write your ID number (810 number, NOT SSN) on every page. Write your initials on the first page only. All of the multiple choice questions have only one correct answer. The exam should
UGA - GENE - 3200
The selection of officeholders oPresident/vice president o12thAmendment : separate electoral ballots oMembers of the House and Senate Different Election Cycles oConcurrence and nonconcurrence Incumbents oA politician running for reelection to the office s
UGA - GENE - 3200
GENE3200 Fall 2010 Bedell Exam 3 Nov 4 ID no. 810 _Write your ID number (810 number, NOT SSN) on every page. Write your initials on the first page only. All of the multiple choice questions have only one correct answer. The exam should be completed in i
UGA - GENE - 3200
GENE3200 Fall 2010 Bedell Exam 3 Nov 4 ID no. 810 _KEY_Write your ID number (810 number, NOT SSN) on every page. Write your initials on the first page only. All of the multiple choice questions have only one correct answer. The exam should be completed
UGA - HIST - 2111
UGA - HIST - 2111
000000January 12thTuesdayWorlds Collide: Europe, Africa, and America 14501620 o Questions to keep in mind throughout the course What are the hallmarks of Native Americans' culture? Was the European conquest of the Indians inevitable? How do plants, mic
UGA - HIST - 2111
000000Tuesday January 12, 2010 The Politics of Pre-Columbian American History 95 % of history took place before Columbus arrival 4 Main Questions Where did first Americans come from? o Traditional story, they came across the Bering strait from Asia,- kno
UGA - CHEM - 2211
Interest Groups oOrganizations of people who share common political interests and aim to influence public policy by electioneering and lobbying oBrings us back to Federalist #10 and James Madison factions oInterest Groups are essentially organized faction
UGA - CHEM - 2211
Introduction: For the average college aged adult, sleep deprivation is a common dilemma. In order to satisfy the demands of rigorous course work, students will deprive themselves of a healthy amount of sleep, which has been calculated to be 8 to 9 hours.
UGA - CHEM - 2211
volume of distillate in ml 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15Temperature in Celcius 75 77 79 80.5 82 84 84.8 88 90.5 94 97 97.5 98 98 98 98120 100Simple DistillationTemperature in Celcius80 60 40 20 0 0 2 4 6 8 10 12 14 16Volume in mlvolume of d
UGA - CHEM - 2211
Experiment #10 The Aldol Condensation The aldol condensation is the name given to the reaction in which the conjugate base of an aldehyde or a ketone (ie. the anion derived by removal of a proton from a carbon adjacent to the carbonyl group) adds to the c
UGA - CHEM - 2211
Hydrometallurgy to Analyze a Chromite Sample Formal Lab Reportl Haley Gowen Michele Chan Amanda Huels Drew Benz October 17th, 2009Introduction Chromite is an oxide mineral and is the only ore of chromium, which has many industrial uses. Chromium is used
UGA - CHEM - 2211
Hydrometallurgy to Analyze a Chromite Sample Formal Lab Report Haley Gowen Michele Chan Amanda Huels Drew Benz October 17th, 2009Introduction Chromite is an oxide mineral and is the only ore of chromium, which has many industrial uses. Chromium is used t
UGA - CHEM - 2211
Michele Chan 2211L 9/23/10 Adna Muliawan Discussion According to the graphs and the results obtained from the two types of distillation, fractional distillation appeared to be more accurate. The boiling point for simple distillation was 75 degree Celcius