SlideShare a Scribd company logo
1 of 31
Hamming Codes
11/17/04
History
 In the late 1940’s Richard Hamming recognized
that the further evolution of computers required
greater reliability, in particular the ability to not
only detect errors, but correct them. His search
for error-correcting codes led to the Hamming
Codes, perfect 1-error correcting codes, and the
extended Hamming Codes, 1-error correcting
and 2-error detecting codes.
Uses
 Hamming Codes are still widely used in
computing, telecommunication, and other
applications.
 Hamming Codes also applied in
 Data compression
 Some solutions to the popular puzzle The Hat
Game
 Block Turbo Codes
A [7,4] binary Hamming Code
 Let our codeword be (x1 x2 … x7) ε F2
7
 x3, x5, x6, x7 are chosen according to the message
(perhaps the message itself is (x3 x5 x6 x7 )).
 x4 := x5 + x6 + x7 (mod 2)
 x2 := x3 + x6 + x7
 x1 := x3 + x5 + x7
[7,4] binary Hamming codewords
A [7,4] binary Hamming Code
 Let a = x4 + x5 + x6 + x7 (=1 iff one of these
bits is in error)
 Let b = x2 + x3 + x6 + x7
 Let c = x1 + x3 + x5 + x7
 If there is an error (assuming at most one) then
abc will be binary representation of the
subscript of the offending bit.
A [7,4] binary Hamming Code
 If (y1 y2 … y7) is received and abc ≠ 000, then
we assume the bit abc is in error and switch it.
If abc=000, we assume there were no errors (so
if there are three or more errors we may recover
the wrong codeword).
Definition: Generator and Check
Matrices
 For an [n, k] linear code, the generator matrix is
a k×n matrix for which the row space is the
given code.
 A check matrix for an [n, k] is a generator matrix
for the dual code. In other words, an (n-k)×k
matrix M for which Mx = 0 for all x in the
code.
A Construction for binary Hamming
Codes
 For a given r, form an r × 2r-1 matrix M, the
columns of which are the binary representations
(r bits long) of 1, …, 2r-1.
 The linear code for which this is the check
matrix is a [2r-1, 2r-1 – r] binary Hamming Code
= {x=(x1 x2 … x n) : MxT = 0}.
Example Check Matrix
 A check matrix for a [7,4] binary Hamming
Code:
Syndrome Decoding
 Let y = (y1 y2 … yn) be a received codeword.
 The syndrome of y is S:=LryT. If S=0 then
there was no error. If S ≠ 0 then S is the binary
representation of some integer 1 ≤ t ≤ n=2r-1
and the intended codeword is
x = (y1 … yr+1 … yn).
Example Using L3
 Suppose (1 0 1 0 0 1 0) is received.
100 is 4 in binary, so the intended codeword was
(1 0 1 1 0 1 0).
Extended [8,4] binary Hamm. Code
 As with the [7,4] binary Hamming Code:
 x3, x5, x6, x7 are chosen according to the message.
 x4 := x5 + x6 + x7
 x2 := x3 + x6 + x7
 x1 := x3 + x5 + x7
 Add a new bit x0 such that
 x0 = x1 + x2 + x3 + x4 + x5 + x6 + x7 . i.e., the new
bit makes the sum of all the bits zero. x0 is called a
parity check.
Extended binary Hamming Code
 The minimum distance between any two
codewords is now 4, so an extended Hamming
Code is a 1-error correcting and 2-error
detecting code.
 The general construction of a [2r, 2r-1 - r]
extended code from a [2r –1, 2r –1 – r] binary
Hamming Code is the same: add a parity check
bit.
Check Matrix Construction of
Extended Hamming Code
 The check matrix of an extended Hamming
Code can be constructed from the check matrix
of a Hamming code by adding a zero column on
the left and a row of 1’s to the bottom.
Decoding Extended Hamming Code
q-ary Hamming Codes
 The binary construction generalizes to
Hamming Codes over an alphabet A={0, …, q},
q ≥ 2.
 For a given r, form an r × (qr-1)/(q-1) matrix M
over A, any two columns of which are linearly
independent.
 M determines a [(qr-1)/(q-1), (qr-1)/(q-1) – r]
(= [n,k]) q-ary Hamming Code for which M is
the check matrix.
Example: ternary [4, 2]
Hamming
 Two check matrices for the some [4, 2] ternary
Hamming Codes:
Syndrome decoding: the q-ary case
 The syndrome of received word y, S:=MyT, will
be a multiple of one of the columns of M, say
S=αmi, α scalar, mi the ith column of M. Assume
an error vector of weight 1 was introduced y =
x + (0 … α … 0), α in the ith spot.
Example: q-ary Syndrome
 [4,2] ternary with check matrix ,
word (0 1 1 1) received.
 So decode (0 1 1 1) as
(0 1 1 1) – (0 0 2 0) = (0 1 2 1).
Perfect 1-error correcting
 Hamming Codes are perfect 1-error correcting
codes. That is, any received word with at most
one error will be decoded correctly and the code
has the smallest possible size of any code that
does this.
 For a given r, any perfect 1-error correcting
linear code of length n=2r-1 and dimension n-r
is a Hamming Code.
Proof: 1-error correcting
 A code will be 1-error correcting if
 spheres of radius 1 centered at codewords cover the
codespace, and
 if the minimum distance between any two
codewords ≥ 3, since then spheres of radius 1
centered at codewords will be disjoint.
Proof: 1-error correcting
 Suppose codewords x, y differ by 1 bit. Then
x-y is a codeword of weight 1, and M(x-y) ≠ 0.
Contradiction. If x, y differ by 2 bits, then
M(x-y) is the difference of two multiples of
columns of M. No two columns of M are
linearly dependent, so M(x-y) ≠ 0, another
contradiction. Thus the minimum distance is at
least 3.
Perfect
 A sphere of radius δ centered at x is
Sδ(x)={y in An : dH(x,y) ≤ δ}. Where A is the
alphabet, Fq, and dH is the Hamming distance.
 A sphere of radius e contains
words.
 If C is an e-error correcting code then
, so .
Perfect
 This last inequality is called the sphere packing
bound for an e-error correcting code C of
length n over Fm:
where n
is the length of the code and in this case e=1.
 A code for which equality holds is called perfect.
Proof: Perfect
 The right side of this, for e=1 is qn/(1+n(q-1)).
 The left side is qn-r where n= (qr-1)/(q-1).
qn-r(1+n(q-1)) = qn-r(1+(qr-1)) = qn.
Applications
 Data compression.
 Turbo Codes
 The Hat Game
Data Compression
 Hamming Codes can be used for a form of
lossy compression.
 If n=2r-1 for some r, then any n-tuple of bits x
is within distance at most 1 from a Hamming
codeword c. Let G be a generator matrix for
the Hamming Code, and mG=c.
 For compression, store x as m. For
decompression, decode m as c. This saves r bits
of space but corrupts (at most) 1 bit.
The Hat Game
 A group of n players enter a room whereupon
they each receive a hat. Each player can see
everyone else’s hat but not his own.
 The players must each simultaneously guess a
hat color, or pass.
 The group loses if any player guesses the wrong
hat color or if every player passes.
 Players are not necessarily anonymous, they can
be numbered.
The Hat Game
 Assignment of hats is assumed to be random.
 The players can meet beforehand to devise a
strategy.
 The goal is to devise the strategy that gives the
highest probability of winning.
Source
 “Notes on Coding Theory” by J.I. Hall
http://www.mth.msu.edu/~jhall/classes/coden
otes/coding-notes.html

More Related Content

What's hot

Error Correction And Hamming Code Ibrar
Error Correction And Hamming Code IbrarError Correction And Hamming Code Ibrar
Error Correction And Hamming Code Ibraribrar562
 
Error detection & correction codes
Error detection & correction codesError detection & correction codes
Error detection & correction codesRevathi Subramaniam
 
Digital Data, Digital Signal | Scrambling Techniques
Digital Data, Digital Signal | Scrambling TechniquesDigital Data, Digital Signal | Scrambling Techniques
Digital Data, Digital Signal | Scrambling TechniquesBiplap Bhattarai
 
Presentation on cyclic redundancy check (crc)
Presentation on cyclic redundancy check (crc)Presentation on cyclic redundancy check (crc)
Presentation on cyclic redundancy check (crc)Sudhanshu Srivastava
 
Digital Communication: Channel Coding
Digital Communication: Channel CodingDigital Communication: Channel Coding
Digital Communication: Channel CodingDr. Sanjay M. Gulhane
 
Chapter 10: Error Correction and Detection
Chapter 10: Error Correction and DetectionChapter 10: Error Correction and Detection
Chapter 10: Error Correction and DetectionJeoffnaRuth
 
Linear block coding
Linear block codingLinear block coding
Linear block codingjknm
 
Time Division Multiplexing
Time Division MultiplexingTime Division Multiplexing
Time Division MultiplexingSpandit Lenka
 
Error Detection and Correction presentation
Error Detection and Correction presentation Error Detection and Correction presentation
Error Detection and Correction presentation Badrul Alam
 
EC8562 DSP Viva Questions
EC8562 DSP Viva Questions EC8562 DSP Viva Questions
EC8562 DSP Viva Questions ssuser2797e4
 

What's hot (20)

BCH CODE AND DECODING BCH
BCH CODE AND DECODING BCHBCH CODE AND DECODING BCH
BCH CODE AND DECODING BCH
 
Huffman codes
Huffman codesHuffman codes
Huffman codes
 
Error Correction And Hamming Code Ibrar
Error Correction And Hamming Code IbrarError Correction And Hamming Code Ibrar
Error Correction And Hamming Code Ibrar
 
Convolutional codes
Convolutional codesConvolutional codes
Convolutional codes
 
Reed solomon code
Reed solomon codeReed solomon code
Reed solomon code
 
Source coding
Source coding Source coding
Source coding
 
Error detection & correction codes
Error detection & correction codesError detection & correction codes
Error detection & correction codes
 
Convolution Codes
Convolution CodesConvolution Codes
Convolution Codes
 
Huffman Coding
Huffman CodingHuffman Coding
Huffman Coding
 
Digital Data, Digital Signal | Scrambling Techniques
Digital Data, Digital Signal | Scrambling TechniquesDigital Data, Digital Signal | Scrambling Techniques
Digital Data, Digital Signal | Scrambling Techniques
 
Presentation on cyclic redundancy check (crc)
Presentation on cyclic redundancy check (crc)Presentation on cyclic redundancy check (crc)
Presentation on cyclic redundancy check (crc)
 
Digital Communication: Channel Coding
Digital Communication: Channel CodingDigital Communication: Channel Coding
Digital Communication: Channel Coding
 
Chapter 10: Error Correction and Detection
Chapter 10: Error Correction and DetectionChapter 10: Error Correction and Detection
Chapter 10: Error Correction and Detection
 
Linear block coding
Linear block codingLinear block coding
Linear block coding
 
Huffman coding
Huffman coding Huffman coding
Huffman coding
 
Turbo codes.ppt
Turbo codes.pptTurbo codes.ppt
Turbo codes.ppt
 
Time Division Multiplexing
Time Division MultiplexingTime Division Multiplexing
Time Division Multiplexing
 
Shannon Fano
Shannon FanoShannon Fano
Shannon Fano
 
Error Detection and Correction presentation
Error Detection and Correction presentation Error Detection and Correction presentation
Error Detection and Correction presentation
 
EC8562 DSP Viva Questions
EC8562 DSP Viva Questions EC8562 DSP Viva Questions
EC8562 DSP Viva Questions
 

Similar to Hamming codes

basicsofcodingtheory-160202182933-converted.pptx
basicsofcodingtheory-160202182933-converted.pptxbasicsofcodingtheory-160202182933-converted.pptx
basicsofcodingtheory-160202182933-converted.pptxupendrabhatt13
 
Coding theory.pdf
Coding theory.pdfCoding theory.pdf
Coding theory.pdf230231060
 
Review paper on Reed Solomon (204,188) Decoder for Digital Video Broadcasting...
Review paper on Reed Solomon (204,188) Decoder for Digital Video Broadcasting...Review paper on Reed Solomon (204,188) Decoder for Digital Video Broadcasting...
Review paper on Reed Solomon (204,188) Decoder for Digital Video Broadcasting...IRJET Journal
 
Reed_Solomon_Implementation
Reed_Solomon_ImplementationReed_Solomon_Implementation
Reed_Solomon_Implementationramya c b
 
The International Journal of Engineering and Science (The IJES)
The International Journal of Engineering and Science (The IJES)The International Journal of Engineering and Science (The IJES)
The International Journal of Engineering and Science (The IJES)theijes
 
Huffman coding
Huffman codingHuffman coding
Huffman codingGeorge Ang
 
Error Detection N Correction
Error Detection N CorrectionError Detection N Correction
Error Detection N CorrectionAnkan Adhikari
 
Justesen codes alternant codes goppa codes
Justesen codes alternant codes goppa codesJustesen codes alternant codes goppa codes
Justesen codes alternant codes goppa codesMadhumita Tamhane
 
Weight enumerators of block codes and the mc williams
Weight  enumerators of block codes and  the mc williamsWeight  enumerators of block codes and  the mc williams
Weight enumerators of block codes and the mc williamsMadhumita Tamhane
 
13-DataLink_02.ppt
13-DataLink_02.ppt13-DataLink_02.ppt
13-DataLink_02.pptWinterSnow16
 
art_sklar7_reed-solomon
art_sklar7_reed-solomonart_sklar7_reed-solomon
art_sklar7_reed-solomonAniruddh Tyagi
 
art_sklar7_reed-solomon
art_sklar7_reed-solomonart_sklar7_reed-solomon
art_sklar7_reed-solomonaniruddh Tyagi
 
art_sklar7_reed-solomon
art_sklar7_reed-solomonart_sklar7_reed-solomon
art_sklar7_reed-solomonaniruddh Tyagi
 

Similar to Hamming codes (20)

basicsofcodingtheory-160202182933-converted.pptx
basicsofcodingtheory-160202182933-converted.pptxbasicsofcodingtheory-160202182933-converted.pptx
basicsofcodingtheory-160202182933-converted.pptx
 
Coding theory.pdf
Coding theory.pdfCoding theory.pdf
Coding theory.pdf
 
rs_1.pptx
rs_1.pptxrs_1.pptx
rs_1.pptx
 
Review paper on Reed Solomon (204,188) Decoder for Digital Video Broadcasting...
Review paper on Reed Solomon (204,188) Decoder for Digital Video Broadcasting...Review paper on Reed Solomon (204,188) Decoder for Digital Video Broadcasting...
Review paper on Reed Solomon (204,188) Decoder for Digital Video Broadcasting...
 
Linear block code
Linear block codeLinear block code
Linear block code
 
Reed_Solomon_Implementation
Reed_Solomon_ImplementationReed_Solomon_Implementation
Reed_Solomon_Implementation
 
The International Journal of Engineering and Science (The IJES)
The International Journal of Engineering and Science (The IJES)The International Journal of Engineering and Science (The IJES)
The International Journal of Engineering and Science (The IJES)
 
Huffman Coding
Huffman CodingHuffman Coding
Huffman Coding
 
Basics of coding theory
Basics of coding theoryBasics of coding theory
Basics of coding theory
 
5 linear block codes
5 linear block codes5 linear block codes
5 linear block codes
 
Huffman coding
Huffman codingHuffman coding
Huffman coding
 
linear codes and cyclic codes
linear codes and cyclic codeslinear codes and cyclic codes
linear codes and cyclic codes
 
Error Detection N Correction
Error Detection N CorrectionError Detection N Correction
Error Detection N Correction
 
Justesen codes alternant codes goppa codes
Justesen codes alternant codes goppa codesJustesen codes alternant codes goppa codes
Justesen codes alternant codes goppa codes
 
Weight enumerators of block codes and the mc williams
Weight  enumerators of block codes and  the mc williamsWeight  enumerators of block codes and  the mc williams
Weight enumerators of block codes and the mc williams
 
13-DataLink_02.ppt
13-DataLink_02.ppt13-DataLink_02.ppt
13-DataLink_02.ppt
 
Data links
Data links Data links
Data links
 
art_sklar7_reed-solomon
art_sklar7_reed-solomonart_sklar7_reed-solomon
art_sklar7_reed-solomon
 
art_sklar7_reed-solomon
art_sklar7_reed-solomonart_sklar7_reed-solomon
art_sklar7_reed-solomon
 
art_sklar7_reed-solomon
art_sklar7_reed-solomonart_sklar7_reed-solomon
art_sklar7_reed-solomon
 

Recently uploaded

A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 

Recently uploaded (20)

A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 

Hamming codes

  • 2. History  In the late 1940’s Richard Hamming recognized that the further evolution of computers required greater reliability, in particular the ability to not only detect errors, but correct them. His search for error-correcting codes led to the Hamming Codes, perfect 1-error correcting codes, and the extended Hamming Codes, 1-error correcting and 2-error detecting codes.
  • 3. Uses  Hamming Codes are still widely used in computing, telecommunication, and other applications.  Hamming Codes also applied in  Data compression  Some solutions to the popular puzzle The Hat Game  Block Turbo Codes
  • 4. A [7,4] binary Hamming Code  Let our codeword be (x1 x2 … x7) ε F2 7  x3, x5, x6, x7 are chosen according to the message (perhaps the message itself is (x3 x5 x6 x7 )).  x4 := x5 + x6 + x7 (mod 2)  x2 := x3 + x6 + x7  x1 := x3 + x5 + x7
  • 6. A [7,4] binary Hamming Code  Let a = x4 + x5 + x6 + x7 (=1 iff one of these bits is in error)  Let b = x2 + x3 + x6 + x7  Let c = x1 + x3 + x5 + x7  If there is an error (assuming at most one) then abc will be binary representation of the subscript of the offending bit.
  • 7. A [7,4] binary Hamming Code  If (y1 y2 … y7) is received and abc ≠ 000, then we assume the bit abc is in error and switch it. If abc=000, we assume there were no errors (so if there are three or more errors we may recover the wrong codeword).
  • 8. Definition: Generator and Check Matrices  For an [n, k] linear code, the generator matrix is a k×n matrix for which the row space is the given code.  A check matrix for an [n, k] is a generator matrix for the dual code. In other words, an (n-k)×k matrix M for which Mx = 0 for all x in the code.
  • 9. A Construction for binary Hamming Codes  For a given r, form an r × 2r-1 matrix M, the columns of which are the binary representations (r bits long) of 1, …, 2r-1.  The linear code for which this is the check matrix is a [2r-1, 2r-1 – r] binary Hamming Code = {x=(x1 x2 … x n) : MxT = 0}.
  • 10. Example Check Matrix  A check matrix for a [7,4] binary Hamming Code:
  • 11. Syndrome Decoding  Let y = (y1 y2 … yn) be a received codeword.  The syndrome of y is S:=LryT. If S=0 then there was no error. If S ≠ 0 then S is the binary representation of some integer 1 ≤ t ≤ n=2r-1 and the intended codeword is x = (y1 … yr+1 … yn).
  • 12. Example Using L3  Suppose (1 0 1 0 0 1 0) is received. 100 is 4 in binary, so the intended codeword was (1 0 1 1 0 1 0).
  • 13. Extended [8,4] binary Hamm. Code  As with the [7,4] binary Hamming Code:  x3, x5, x6, x7 are chosen according to the message.  x4 := x5 + x6 + x7  x2 := x3 + x6 + x7  x1 := x3 + x5 + x7  Add a new bit x0 such that  x0 = x1 + x2 + x3 + x4 + x5 + x6 + x7 . i.e., the new bit makes the sum of all the bits zero. x0 is called a parity check.
  • 14. Extended binary Hamming Code  The minimum distance between any two codewords is now 4, so an extended Hamming Code is a 1-error correcting and 2-error detecting code.  The general construction of a [2r, 2r-1 - r] extended code from a [2r –1, 2r –1 – r] binary Hamming Code is the same: add a parity check bit.
  • 15. Check Matrix Construction of Extended Hamming Code  The check matrix of an extended Hamming Code can be constructed from the check matrix of a Hamming code by adding a zero column on the left and a row of 1’s to the bottom.
  • 17. q-ary Hamming Codes  The binary construction generalizes to Hamming Codes over an alphabet A={0, …, q}, q ≥ 2.  For a given r, form an r × (qr-1)/(q-1) matrix M over A, any two columns of which are linearly independent.  M determines a [(qr-1)/(q-1), (qr-1)/(q-1) – r] (= [n,k]) q-ary Hamming Code for which M is the check matrix.
  • 18. Example: ternary [4, 2] Hamming  Two check matrices for the some [4, 2] ternary Hamming Codes:
  • 19. Syndrome decoding: the q-ary case  The syndrome of received word y, S:=MyT, will be a multiple of one of the columns of M, say S=αmi, α scalar, mi the ith column of M. Assume an error vector of weight 1 was introduced y = x + (0 … α … 0), α in the ith spot.
  • 20. Example: q-ary Syndrome  [4,2] ternary with check matrix , word (0 1 1 1) received.  So decode (0 1 1 1) as (0 1 1 1) – (0 0 2 0) = (0 1 2 1).
  • 21. Perfect 1-error correcting  Hamming Codes are perfect 1-error correcting codes. That is, any received word with at most one error will be decoded correctly and the code has the smallest possible size of any code that does this.  For a given r, any perfect 1-error correcting linear code of length n=2r-1 and dimension n-r is a Hamming Code.
  • 22. Proof: 1-error correcting  A code will be 1-error correcting if  spheres of radius 1 centered at codewords cover the codespace, and  if the minimum distance between any two codewords ≥ 3, since then spheres of radius 1 centered at codewords will be disjoint.
  • 23. Proof: 1-error correcting  Suppose codewords x, y differ by 1 bit. Then x-y is a codeword of weight 1, and M(x-y) ≠ 0. Contradiction. If x, y differ by 2 bits, then M(x-y) is the difference of two multiples of columns of M. No two columns of M are linearly dependent, so M(x-y) ≠ 0, another contradiction. Thus the minimum distance is at least 3.
  • 24. Perfect  A sphere of radius δ centered at x is Sδ(x)={y in An : dH(x,y) ≤ δ}. Where A is the alphabet, Fq, and dH is the Hamming distance.  A sphere of radius e contains words.  If C is an e-error correcting code then , so .
  • 25. Perfect  This last inequality is called the sphere packing bound for an e-error correcting code C of length n over Fm: where n is the length of the code and in this case e=1.  A code for which equality holds is called perfect.
  • 26. Proof: Perfect  The right side of this, for e=1 is qn/(1+n(q-1)).  The left side is qn-r where n= (qr-1)/(q-1). qn-r(1+n(q-1)) = qn-r(1+(qr-1)) = qn.
  • 27. Applications  Data compression.  Turbo Codes  The Hat Game
  • 28. Data Compression  Hamming Codes can be used for a form of lossy compression.  If n=2r-1 for some r, then any n-tuple of bits x is within distance at most 1 from a Hamming codeword c. Let G be a generator matrix for the Hamming Code, and mG=c.  For compression, store x as m. For decompression, decode m as c. This saves r bits of space but corrupts (at most) 1 bit.
  • 29. The Hat Game  A group of n players enter a room whereupon they each receive a hat. Each player can see everyone else’s hat but not his own.  The players must each simultaneously guess a hat color, or pass.  The group loses if any player guesses the wrong hat color or if every player passes.  Players are not necessarily anonymous, they can be numbered.
  • 30. The Hat Game  Assignment of hats is assumed to be random.  The players can meet beforehand to devise a strategy.  The goal is to devise the strategy that gives the highest probability of winning.
  • 31. Source  “Notes on Coding Theory” by J.I. Hall http://www.mth.msu.edu/~jhall/classes/coden otes/coding-notes.html