SlideShare a Scribd company logo
1 of 19
Source Coding and Kraft
Inequality
Source coding (Data Compression)
• A source code C for a random variable X is a mapping from X,
the range of X, to D∗, the set of finite-length strings of
symbols from a D-ary alphabet.
• Data compression can be achieved by assigning short
descriptions to the most frequent outcomes of the data
source, and necessarily longer descriptions to the less
frequent outcomes.
• Source code C for a random variable X is
• Let C(x) denote the codeword corresponding to
x and let l(x) denote the length of C(x).
• For example, C(red) = 00, C(blue) = 11 is a
source code for X = {red, blue} with alphabet D
= {0, 1}.
• The expected length L(C) of a source code C(x)
for a random variable X with probability mass
function p(x) is given by
Example
• Let X be a random variable with the following distribution and
codeword assignment:
Pr(X = 1) = ½ , codeword C(1) = 0
Pr(X = 2) = ¼ , codeword C(2) = 10
Pr(X = 3) = 1/8 , codeword C(3) = 110
Pr(X = 4) = 1/8 , codeword C(4) = 111.
• The entropy H(X) of X is 1.75 bits, and the expected length L(C) =
El(X) of this code is also 1.75 bits.
• Here we have a code that has the same average length as the
entropy.
• We note that any sequence of bits can be uniquely decoded into a
sequence of symbols of X.
• For example, the bit string 0110111100110 is decoded as 134213.
• Consider another simple example of a code for a
random variable:
Pr(X = 1) = 1/3 , codeword C(1) = 0
Pr(X = 2) = 1/3 , codeword C(2) = 10
Pr(X = 3) = 1/3 , codeword C(3) = 11.
• The code is uniquely decodable.
• However, in this case the entropy is log 3 = 1.58
bits and the average length of the encoding is
1.66 bits.
• Here El(X) > H(X).
Morse's code
• The Morse code is a reasonably efficient code
for the English alphabet using an alphabet of
four symbols: a dot, a dash, a letter space,
and a word space.
• Developed for electric telegraph system
• D = (dot, dash, letter space, word space)
• Short sequences represent frequent letters
• Long sequences represent infrequent letter
Source coding applications
• Magnetic recording: cassette, hardrive, USB...
• Speech compression
• Compact disk (CD)
• Image compression: JPEG
• Still an active area of research:
• Solid state hard drive
• Sensor network: distributed source coding
Classes of Codes
• Non – Singular
• Extension
• Uniquely decodable
• Prefix codes
Non singular
• A code is said to be non singular if every element of the
range of X maps into a different string in D∗; that is,
• No two elements of X can have the same codeword
• Non singularity suffices for an unambiguous description of
a single value of X.
• But we usually wish to send a sequence of values of X.
• In such cases we can ensure decodability by adding a
special symbol (a “comma”) between any two codewords.
• But this is an inefficient use of the special symbol; we can
do better by developing the idea of self punctuating or
instantaneous codes
Extension
• The extension C∗ of a code C is the mapping
from finite length strings of X to finite-length
strings of D, defined by
• where C(x1)C(x2) · · · C(xn) indicates
concatenation of the corresponding
codewords.
• If C(x1) = 00 and C(x2) = 11, then C(x1x2) =
0011.
Uniquely Decodable
• A code is called uniquely decodable if its
extension is nonsingular.
• Concatenation of two codewords should not
results into another codeword
• In other words, any encoded string in a uniquely
decodable code has only one possible source
string producing it.
• However, one may have to look at the entire
string to determine even the first symbol in the
corresponding source string.
Prefix code
• A code is called a prefix code or an instantaneous code
if no codeword is a prefix of any other codeword.
• An instantaneous code can be decoded without
reference to future codewords since the end of a
codeword is immediately recognizable.
• Hence, for an instantaneous code, the symbol xi can be
decoded as soon as we come to the end of the
codeword corresponding to it.
• We need not wait to see the codewords that come
later.
• An instantaneous code is a selfpunctuating code; we
can look down the sequence of code symbols and add
the commas to separate the codewords without
looking at later symbols.
• The nesting of these definitions is shown
KRAFT INEQUALITY
• We wish to construct instantaneous codes of
minimum expected length to describe a given
source.
• It is clear that we cannot assign short
codewords to all source symbols and still be
prefix-free.
• The set of codeword lengths possible for
instantaneous codes is limited by the
following inequality.
• (Kraft inequality) For any instantaneous code
(prefix code) over an alphabet of size D, the
codeword lengths L1, L2, . . . , Lm must satisfy
the inequality
• Conversely, given a set of codeword lengths
that satisfy this inequality, there exists an
instantaneous code with these word lengths.
Assignment
• Group 1: Identify the total number of word that can be
constructed in Swahili language (e.g Hello, Mambo, poa, ni,
na, etc). Then Develop codewords for Kiswahili words as
source Elements
• Group 2: Identify the total number of word that can be
constructed in English language (e.g how, and, a, the, one,
for etc). Then Develop codewords for English words as
source Elements
END

More Related Content

Similar to Lecture 3.pptx

Similar to Lecture 3.pptx (20)

image compresson
image compressonimage compresson
image compresson
 
coding.pdf
coding.pdfcoding.pdf
coding.pdf
 
Digital Communication: Channel Coding
Digital Communication: Channel CodingDigital Communication: Channel Coding
Digital Communication: Channel Coding
 
Losseless
LosselessLosseless
Losseless
 
Hossein Taghavi : Codes on Graphs
Hossein Taghavi : Codes on GraphsHossein Taghavi : Codes on Graphs
Hossein Taghavi : Codes on Graphs
 
basicsofcodingtheory-160202182933-converted.pptx
basicsofcodingtheory-160202182933-converted.pptxbasicsofcodingtheory-160202182933-converted.pptx
basicsofcodingtheory-160202182933-converted.pptx
 
Presentation ppt 3.pptx
Presentation ppt 3.pptxPresentation ppt 3.pptx
Presentation ppt 3.pptx
 
Komdat-Kompresi Data
Komdat-Kompresi DataKomdat-Kompresi Data
Komdat-Kompresi Data
 
Turbo Code
Turbo Code Turbo Code
Turbo Code
 
Unequal-Cost Prefix-Free Codes
Unequal-Cost Prefix-Free CodesUnequal-Cost Prefix-Free Codes
Unequal-Cost Prefix-Free Codes
 
Compression Ii
Compression IiCompression Ii
Compression Ii
 
Compression Ii
Compression IiCompression Ii
Compression Ii
 
Channel Coding (Error Control Coding)
Channel Coding (Error Control Coding)Channel Coding (Error Control Coding)
Channel Coding (Error Control Coding)
 
Information Theory and coding - Lecture 3
Information Theory and coding - Lecture 3Information Theory and coding - Lecture 3
Information Theory and coding - Lecture 3
 
Data Protection Techniques and Cryptography
Data Protection Techniques and CryptographyData Protection Techniques and Cryptography
Data Protection Techniques and Cryptography
 
Classical encryption techniques
Classical encryption techniquesClassical encryption techniques
Classical encryption techniques
 
Presentation
PresentationPresentation
Presentation
 
Module-IV 094.pdf
Module-IV 094.pdfModule-IV 094.pdf
Module-IV 094.pdf
 
ma92008id393
ma92008id393ma92008id393
ma92008id393
 
Unit-1-part-1.pptx
Unit-1-part-1.pptxUnit-1-part-1.pptx
Unit-1-part-1.pptx
 

Recently uploaded

VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 

Recently uploaded (20)

VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 

Lecture 3.pptx

  • 1. Source Coding and Kraft Inequality
  • 2. Source coding (Data Compression) • A source code C for a random variable X is a mapping from X, the range of X, to D∗, the set of finite-length strings of symbols from a D-ary alphabet. • Data compression can be achieved by assigning short descriptions to the most frequent outcomes of the data source, and necessarily longer descriptions to the less frequent outcomes. • Source code C for a random variable X is
  • 3. • Let C(x) denote the codeword corresponding to x and let l(x) denote the length of C(x). • For example, C(red) = 00, C(blue) = 11 is a source code for X = {red, blue} with alphabet D = {0, 1}. • The expected length L(C) of a source code C(x) for a random variable X with probability mass function p(x) is given by
  • 4. Example • Let X be a random variable with the following distribution and codeword assignment: Pr(X = 1) = ½ , codeword C(1) = 0 Pr(X = 2) = ¼ , codeword C(2) = 10 Pr(X = 3) = 1/8 , codeword C(3) = 110 Pr(X = 4) = 1/8 , codeword C(4) = 111. • The entropy H(X) of X is 1.75 bits, and the expected length L(C) = El(X) of this code is also 1.75 bits. • Here we have a code that has the same average length as the entropy. • We note that any sequence of bits can be uniquely decoded into a sequence of symbols of X. • For example, the bit string 0110111100110 is decoded as 134213.
  • 5. • Consider another simple example of a code for a random variable: Pr(X = 1) = 1/3 , codeword C(1) = 0 Pr(X = 2) = 1/3 , codeword C(2) = 10 Pr(X = 3) = 1/3 , codeword C(3) = 11. • The code is uniquely decodable. • However, in this case the entropy is log 3 = 1.58 bits and the average length of the encoding is 1.66 bits. • Here El(X) > H(X).
  • 6. Morse's code • The Morse code is a reasonably efficient code for the English alphabet using an alphabet of four symbols: a dot, a dash, a letter space, and a word space. • Developed for electric telegraph system • D = (dot, dash, letter space, word space) • Short sequences represent frequent letters • Long sequences represent infrequent letter
  • 7.
  • 8. Source coding applications • Magnetic recording: cassette, hardrive, USB... • Speech compression • Compact disk (CD) • Image compression: JPEG • Still an active area of research: • Solid state hard drive • Sensor network: distributed source coding
  • 9. Classes of Codes • Non – Singular • Extension • Uniquely decodable • Prefix codes
  • 10. Non singular • A code is said to be non singular if every element of the range of X maps into a different string in D∗; that is, • No two elements of X can have the same codeword • Non singularity suffices for an unambiguous description of a single value of X. • But we usually wish to send a sequence of values of X. • In such cases we can ensure decodability by adding a special symbol (a “comma”) between any two codewords. • But this is an inefficient use of the special symbol; we can do better by developing the idea of self punctuating or instantaneous codes
  • 11. Extension • The extension C∗ of a code C is the mapping from finite length strings of X to finite-length strings of D, defined by • where C(x1)C(x2) · · · C(xn) indicates concatenation of the corresponding codewords. • If C(x1) = 00 and C(x2) = 11, then C(x1x2) = 0011.
  • 12. Uniquely Decodable • A code is called uniquely decodable if its extension is nonsingular. • Concatenation of two codewords should not results into another codeword • In other words, any encoded string in a uniquely decodable code has only one possible source string producing it. • However, one may have to look at the entire string to determine even the first symbol in the corresponding source string.
  • 13. Prefix code • A code is called a prefix code or an instantaneous code if no codeword is a prefix of any other codeword. • An instantaneous code can be decoded without reference to future codewords since the end of a codeword is immediately recognizable. • Hence, for an instantaneous code, the symbol xi can be decoded as soon as we come to the end of the codeword corresponding to it. • We need not wait to see the codewords that come later. • An instantaneous code is a selfpunctuating code; we can look down the sequence of code symbols and add the commas to separate the codewords without looking at later symbols.
  • 14. • The nesting of these definitions is shown
  • 15.
  • 16. KRAFT INEQUALITY • We wish to construct instantaneous codes of minimum expected length to describe a given source. • It is clear that we cannot assign short codewords to all source symbols and still be prefix-free. • The set of codeword lengths possible for instantaneous codes is limited by the following inequality.
  • 17. • (Kraft inequality) For any instantaneous code (prefix code) over an alphabet of size D, the codeword lengths L1, L2, . . . , Lm must satisfy the inequality • Conversely, given a set of codeword lengths that satisfy this inequality, there exists an instantaneous code with these word lengths.
  • 18. Assignment • Group 1: Identify the total number of word that can be constructed in Swahili language (e.g Hello, Mambo, poa, ni, na, etc). Then Develop codewords for Kiswahili words as source Elements • Group 2: Identify the total number of word that can be constructed in English language (e.g how, and, a, the, one, for etc). Then Develop codewords for English words as source Elements
  • 19. END