Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard...

40
Elementary Coding Elementary Coding Theory Including Theory Including Hamming and Reed- Hamming and Reed- Solomom Codes with Solomom Codes with Maple and MATLAB Maple and MATLAB Richard Klima Richard Klima Appalachian State Appalachian State University University Boone, North Carolina Boone, North Carolina Neil Sigmon Neil Sigmon Radford University Radford University Radford, Virginia Radford, Virginia

Transcript of Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard...

Page 1: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

Elementary Coding Elementary Coding Theory Including Theory Including

Hamming and Reed-Hamming and Reed-Solomom Codes with Solomom Codes with Maple and MATLABMaple and MATLAB

Richard KlimaRichard KlimaAppalachian State Appalachian State

UniversityUniversity

Boone, North CarolinaBoone, North Carolina

Neil SigmonNeil SigmonRadford UniversityRadford University

Radford, VirginiaRadford, Virginia

Page 2: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

Purpose for PresentationPurpose for Presentation

To demonstrate some applications To demonstrate some applications with error correcting codes with with error correcting codes with MATLAB and MapleMATLAB and Maple Reed-Muller CodesReed-Muller Codes Hamming CodesHamming Codes Reed-Solomon CodesReed-Solomon Codes

Page 3: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

Basic Notation Basic Notation TerminologyTerminology

Coding theoryCoding theory is the study of methods is the study of methods for for efficient and accurate transformation efficient and accurate transformation from one place to another.from one place to another.

A code is a set of codewords A code is a set of codewords representing the messages to be representing the messages to be transferred between two parties.transferred between two parties.

An error-correcting code is a code whereAn error-correcting code is a code whereit is possible to detect and correct errors it is possible to detect and correct errors during the transmission of codewords.during the transmission of codewords.

Page 4: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

ApplicationsApplications Information transmitted by Internet.Information transmitted by Internet. Wireless communication devices.Wireless communication devices. Compact Discs.Compact Discs. Transmission of information from Transmission of information from

satellites.satellites.

Page 5: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

Reed-Muller CodesReed-Muller Codes Invented by I. Reed and D. Muller in Invented by I. Reed and D. Muller in

1954.1954.

Can be constructed using matrices.Can be constructed using matrices.

Can correct a multiple number of Can correct a multiple number of errors.errors.

Was used to perform error correction Was used to perform error correction for the Mariner 9 space probe mission for the Mariner 9 space probe mission to Mars in 1972.to Mars in 1972.

Page 6: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

Hadamard MatricesHadamard Matrices

A matrix A matrix H H is a Hadamard is a Hadamard matrix if all entries of matrix if all entries of HH are 1 or -1 are 1 or -1 and ,and ,

where where I I is the identity matrix. is the identity matrix.

A A normalizednormalized Hadamard matrix is Hadamard matrix is

one where the first row and column one where the first row and column of of HH only contain positive ones. only contain positive ones.

nnnIHH T

nn

Page 7: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

The only normalized Hadamard The only normalized Hadamard matrices of order one and two arematrices of order one and two are

Subsequent normalized Hadamard Subsequent normalized Hadamard

matrices can be generated using the matrices can be generated using the block matrix formulablock matrix formula

11

11 and 1 21 HH

nn

nnn HH

HHH2

Page 8: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

Reed-Muller Code Construction Reed-Muller Code Construction StepsSteps

Construct a normalized Hadamard Construct a normalized Hadamard matrix of order . matrix of order .

Delete the first row and first column of Delete the first row and first column of the normalized Hadamard matrix. the normalized Hadamard matrix. Change all negative ones to zeros. Call Change all negative ones to zeros. Call this matrix this matrix AA..

Change all ones to zeros and zeros to Change all ones to zeros and zeros to ones in the matrix ones in the matrix AA. Call this matrix . Call this matrix BB..

84 k

Page 9: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

Attach a column of all ones to the left Attach a column of all ones to the left of the matrix of the matrix AA and a column of all and a column of all zeros to the left of the matrix zeros to the left of the matrix BB. Call . Call these matrices these matrices scriptscriptAA and and scriptscriptBB, , respectively.respectively.

Stack the matrix Stack the matrix scriptscriptAA on top ofon top of scriptscriptBB.. Add an extra row of all zeros Add an extra row of all zeros and an extra row of all ones to the and an extra row of all ones to the bottom of the matrix.bottom of the matrix.

Page 10: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

The codewords for the code are The codewords for the code are vectors obtained from the rows for vectors obtained from the rows for the resulting matrix. the resulting matrix.

Each codeword Each codeword cc is a vector is a vector consisting over elements in of consisting over elements in of length 4length 4kk..

2Z

Page 11: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

Reed-Muller codes are classified as Reed-Muller codes are classified as

(4(4kk, 2, 2kk) codes, where 4) codes, where 4k k is the length of is the length of

each codeword and each codeword and 22k k is the is the minimum minimum distance distance between codewords.between codewords.

A Reed-Muller code has 8A Reed-Muller code has 8k k codewords.codewords.

Page 12: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

Error Correction for Reed-Muller Error Correction for Reed-Muller CodesCodes

Reed-Muller codes are designed to Reed-Muller codes are designed to correct up to correct up to kk – – 1 errors.1 errors.

Suppose a vector Suppose a vector rr is received. This is received. This vector is compared to all codewords vector is compared to all codewords in the code. The vector in the code. The vector rr will be will be corrected to the codeword that corrected to the codeword that differs from it in differs from it in kk – – 1 or less 1 or less positions.positions.

Page 13: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

MATLAB ExampleMATLAB Example

We generate the Reed-Muller code We generate the Reed-Muller code that was used for in Mariner 9 space that was used for in Mariner 9 space probe used to take pictures of Mars probe used to take pictures of Mars in 1972.in 1972.

The code was constructed using the The code was constructed using the normalized Hadamard (normalized Hadamard (k = k = 8)8). . The code consisted of 64 codewords The code consisted of 64 codewords of length 32 each. The code could of length 32 each. The code could correct up to 7 errors.correct up to 7 errors.

32H

Page 14: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

Before being transmitted, each Before being transmitted, each photograph taken was broken down photograph taken was broken down into a collection of pixels. into a collection of pixels.

Each pixel was assigned one of 64 Each pixel was assigned one of 64 levels of grayness, and then encoded levels of grayness, and then encoded into one of the 64 codewords in the into one of the 64 codewords in the code.code.

Page 15: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

Hamming CodesHamming Codes

First published by Richard Hamming First published by Richard Hamming in 1950.in 1950.

Page 16: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

Used by the telephone industry and Used by the telephone industry and in computer data transfer.in computer data transfer.

Can correct 1 error.Can correct 1 error.

Code is perfect, which says every Code is perfect, which says every message received with errors is message received with errors is uniquely correctable to a codeword.uniquely correctable to a codeword.

Page 17: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

Hamming Codeword Hamming Codeword ConstructionConstruction

Let and be vector Let and be vector spaces with and let spaces with and let GG be a be a

matrix over of full row rank. Thenmatrix over of full row rank. Then

is a subspace of of dimension .is a subspace of of dimension .

The vectors in The vectors in CC form codewords. form codewords.

kZW 2nk nk

2Z

} somefor |{ WwwGvVvC

nZV 2

V k

k2

Page 18: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

The matrix The matrix GG is called the generator is called the generator matrix for the code matrix for the code CC..

The matrix The matrix GG is formed by finding the is formed by finding the nullspace of a matrix nullspace of a matrix HH known as the known as the parity check matrixparity check matrix..

Page 19: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

Hamming codes form a linear [Hamming codes form a linear [n, kn, k] ] code, where the codewords have a code, where the codewords have a length of length of

nn positions and positions and kk is the dimension of is the dimension of the vector space the code forms.the vector space the code forms.

In Hamming codes, andIn Hamming codes, and

for some integer for some integer mm > > 1.1.

mk m 12

12 mn

Page 20: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

The parity check matrix The parity check matrix HH is a matrix is a matrix of size that is formed by of size that is formed by placing as its columns the binary placing as its columns the binary expressions of the integers expressions of the integers . .

The generator matrix The generator matrix G G will be of sizewill be of size

..

If a codeword, then . If a codeword, then .

12,,2,1 m

)12( mm

)12()12( mm m

wGc 0THc

Page 21: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

MATLAB ExampleMATLAB Example

In MATLAB, suppose we demonstrate In MATLAB, suppose we demonstrate how to construct a codeword from the how to construct a codeword from the vector vector

ww = = (10111011110).(10111011110).

Page 22: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

We encode this message using a [15, We encode this message using a [15, 11] Hamming code with generator 11] Hamming code with generator matrix matrix G G formed from the nullspace of formed from the nullspace of the rows of the parity check matrixthe rows of the parity check matrix

101010101010101

110011001100110

111100001111000

111111110000000

H

Page 23: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

Error Correction for Hamming Error Correction for Hamming CodesCodes

Suppose a vector Suppose a vector rr is transmitted and is transmitted and received. If , then received. If , then r r is a is a codeword.codeword.

If not, then the error can be If not, then the error can be corrected by computing corrected by computing where is a vector containing all where is a vector containing all zeros except at the position. zeros except at the position.

0THr

ierc iethi

Page 24: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

The error position The error position ii is determined by is determined by using the fact that .using the fact that .

Since and produce the Since and produce the same column, the column number same column, the column number produced by produced by

gives the error position gives the error position ii..

Ti

T HeHr

THrTiHe

THr

Page 25: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

MATLAB ExampleMATLAB Example

Using a [15, 11] Hamming code, we Using a [15, 11] Hamming code, we demonstrate how to correct the demonstrate how to correct the following received vector.following received vector.

r = r = ((011100010111110011100010111110))

Page 26: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

Reed-Solomon CodesReed-Solomon Codes

Developed by Irving Reed and Developed by Irving Reed and Gustave Solomon in 1960.Gustave Solomon in 1960.

Page 27: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

One of the most widely used error One of the most widely used error correcting code techniques.correcting code techniques.

Ideal at correcting Ideal at correcting errorerror burstsbursts, , where several errors occur close where several errors occur close together.together.

Page 28: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

Important for the Voyager 2 Important for the Voyager 2 satellite’s transmission of pictures of satellite’s transmission of pictures of the outer planets Uranus and the outer planets Uranus and Neptune.Neptune.

Besides satellite communications, Besides satellite communications, Reed Solomon codes are used with Reed Solomon codes are used with wireless communication and with wireless communication and with compact disks.compact disks.

Page 29: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

Example Pictures taken by Example Pictures taken by VoyagerVoyager

Pictures of Uranus and its rings

Page 30: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

Example Pictures taken by Example Pictures taken by VoyagerVoyager

Picture of Neptune and one its moons, Triton

Page 31: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

The Reed-Solomon code implemented The Reed-Solomon code implemented on Voyager 2 was constructed using on Voyager 2 was constructed using a finite field of a finite field of elements represented by the elements represented by the primitive polynomialprimitive polynomial

Codeword Construction in Codeword Construction in Reed-Solomon CodesReed-Solomon Codes

))(/(][2 xpxZF 25628

1)( 2348 xxxxxp

Page 32: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

Codewords for Voyager were obtained by Codewords for Voyager were obtained by taking multiples of the generating taking multiples of the generating polynomialpolynomial

where where a a is a primitive element use to generate . is a primitive element use to generate .

A codeword is formed by computing A codeword is formed by computing the polynomial the polynomial

where where mm((xx)) is a polynomial with is a polynomial with coefficients from the finite field .coefficients from the finite field .

)())(()( 322 axaxaxxg

)(xc

F

F

)()()( xgxmxc

Page 33: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

Each codeword is represented by Each codeword is represented by polynomials of degree less than polynomials of degree less than . .

Each codeword is a vector of length Each codeword is a vector of length 255 with the information transformed 255 with the information transformed in the polynomial’s coefficients.in the polynomial’s coefficients.

255128 )(xc

Page 34: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

Each polynomial coefficient in the Each polynomial coefficient in the codeword is a polynomial of degree < codeword is a polynomial of degree < . Each polynomial coefficient is a . Each polynomial coefficient is a unique element from the finite field . unique element from the finite field .

On Voyager, full color images were On Voyager, full color images were digitized into binary vectors over .digitized into binary vectors over .

8)( xp

F

2Z

Page 35: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

The binary vectors can be represented The binary vectors can be represented in “blocks” of length 8 as the in “blocks” of length 8 as the coefficients of polynomials of degree < coefficients of polynomials of degree < pp((xx)) = 8. For example, = 8. For example,

In binary, the length of each codeword In binary, the length of each codeword converts to a vector of length of converts to a vector of length of

74321)10111001( aaaa

2040)12())((deg 8 xp

Page 36: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

A codeword A codeword has the property has the property thatthat

for . This gives a for . This gives a technique for verifying a transmitted technique for verifying a transmitted message is a codeword.message is a codeword.

0)( iac 32,,1 i

)(xc

Error Correction in Error Correction in Reed-Solomon CodesReed-Solomon Codes

Page 37: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

If a transmitted message If a transmitted message rr((xx)) is is received that is not a codeword, a received that is not a codeword, a polynomial polynomial ee((xx)) is computed to is computed to correct its coefficients by forming correct its coefficients by forming . .

The Voyager 2 Reed-Solomon code The Voyager 2 Reed-Solomon code could correct up to could correct up to polynomial coefficient errors. This polynomial coefficient errors. This translates to a minimum of 121 translates to a minimum of 121 errors in binary.errors in binary.

)()()( xcxexr

162/32

Page 38: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

Finding Finding ee((xx)) involves performing involves performing computations involving the Euclidean computations involving the Euclidean algorithm and polynomial algorithm and polynomial differentiation.differentiation.

Page 39: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

Maple ExampleMaple Example

Involves user-written proceduresInvolves user-written procedures bincoeffbincoeff binwordbinword rscoeffrscoeff rseuclidrseuclid

We demonstrate both the codeword We demonstrate both the codeword construction and error correction construction and error correction process.process.

Page 40: Elementary Coding Theory Including Hamming and Reed-Solomom Codes with Maple and MATLAB Richard Klima Appalachian State University Boone, North Carolina.

ReferencesReferences

R. E. Klima, N. P. Sigmon, and E. L. R. E. Klima, N. P. Sigmon, and E. L. Stitzinger, Stitzinger, Applications of Abstract Applications of Abstract Algebra with Maple, Algebra with Maple, CRC Press, Llc, Boca CRC Press, Llc, Boca Raton, FL 2000.Raton, FL 2000.

Stephen B. Wicker and Vijay K Bhargava, Stephen B. Wicker and Vijay K Bhargava, editors: editors: Reed-SolomonReed-Solomon Codes and their Codes and their ApplicationsApplications, The Institute of Electrical , The Institute of Electrical and Electronics Engineers, Inc., New York, and Electronics Engineers, Inc., New York, NY 1994.NY 1994.