Error Correction Codes
Error Correction Codes
15-853 Page1
Mathematicians are like Frenchmen:
whatever you say to them they translate
into their own language and forthwith it is
something entirely different.
- Goethe
15-853 Page2
General Model
message (m) Errors introduced by the
noisy channel:
coder • changed fields in the
codeword (e.g. a
codeword (c) flipped bit)
noisy • missing fields in the
channel codeword (e.g. a lost
byte). Called erasures
codeword’ (c’)
How the decoder deals
decoder with errors.
• error detection vs.
• error correction
message or error
15-853 Page3
Applications
• Storage: CDs, DVDs, “hard drives”,
• Wireless: Cell phones, wireless links
• Satellite and Space: TV, Mars rover, …
• Digital Television: DVD, MPEG2 layover
• High Speed Modems: ADSL, DSL, ..
15-853 Page4
Block Codes
message (m) Each message and codeword
is of fixed size
coder = codeword alphabet
codeword (c)
k =|m| n = |c| q = ||
C n (codewords)
noisy
channel (x,y) = number of positions
s.t. xi yi
codeword’ (c’)
d = min{(x,y) : x,y C, x y}
decoder s = max{(c,c’)} that the code
can correct
message or error Code described as: (n,k,d)q
15-853 Page5
Hierarchy of Codes
linear C forms a linear subspace of n
of dimension k
C is linear and
cyclic c0c1c2…cn-1 is a codeword implies
c1c2…cn-1c0 is a codeword
BCH
Bose-Chaudhuri-Hochquenghem
Hamming Reed-Solomon
15-853 Page7
Hypercube Interpretation
Consider codewords as vertices on a hypercube.
110 111
codeword
010 011
d = 2 = min distance
100
101 n = 3 = dimensionality
001
2n = 8 = number of nodes
000
10 11 010 011
100
101
00 01 000 001
2 bits 3 bits
0 -> 00, 1-> 11 0 -> 000, 1-> 111
(n=2,k=1,d=2) (n=3,k=1,d=3)
15-853 Page11
Error Correcting Multibit Messages
We will first discuss Hamming Codes
Detect and correct 1-bit errors.
15-853 Page12
Hamming Codes: Encoding
Localizing error to top or bottom half 1xxx or 0xxx
m15 m14 m13 m12 m11 m10 m9 p8 m7 m6 m5 m3 p0
p8 = m15 m14 m13 m12 m11 m10 m9
Localizing error to x1xx or x0xx
m15 m14 m13 m12 m11 m10 m9 p8 m7 m6 m5 p4 m3 m2 p0
p4 = m15 m14 m13 m12 m7 m6 m5
Localizing error to xx1x or xx0x
m15 m14 m13 m12 m11 m10 m9 p8 m7 m6 m5 p4 m3 p2 p0
p2 = m15 m14 m11 m10 m7 m6 m3
Localizing error to xxx1 or xxx0
m15 m14 m13 m12 m11 m10 m9 p8 m7 m6 m5 p4 m3 p2 p1 p0
p1 = m15 m13 m11 m9 m7 m5 m3
15-853 Page13
Hamming Codes: Decoding
m15 m14 m13 m12 m11 m10 m9 p8 m7 m6 m5 p4 m3 p2 p1 p0
15-853 Page15
Lower bound on parity bits
How many nodes in hypercube do we need so that d = 3?
Each of the 2k codewords eliminates n neighbors plus
itself, i.e. n+1
2n (n 1)2k
n k log 2 (n 1)
n k log 2 (n 1)
In previous hamming code 15 11 + log2(15+1) = 15
Hamming Codes are called perfect codes since they
match the lower bound exactly
15-853 Page16
Lower bound on parity bits
What about fixing 2 errors (i.e. d=5)?
Each of the 2k codewords eliminates itself, its
n n
neighbors and its neighbors’ neighbors, giving: 1
1 2
n k
2 (1 n n(n 1) / 2)2
n k log 2 (1 n n(n 1) / 2)
k 2 log 2 n 1
Generally to correct s errors:
n n n
n k log 2 (1 )
1 2 s
15-853 Page17
Lower Bounds: a side note
The lower bounds assume random placement of bit
errors.
In practice errors are likely to be less than random, e.g.
evenly spaced or clustered:
x x x x x x
x xxxxx
Can we do better if we assume regular errors?
15-853 Page19
Linear Codes
Basis vectors for the (7,4,3)2 Hamming code:
m 7 m 6 m 5 p4 m 3 p2 p1
v1 = 1 0 0 1 0 1 1
v2 = 0 1 0 1 0 1 0
v3 = 0 0 1 1 0 0 1
v4 = 0 0 0 0 1 1 1
How can we see that d = 3?
15-853 Page20
Generator and Parity Check Matrices
Generator Matrix:
A k x n matrix G such that: C = {xG | x k}
Made from stacking the basis vectors
Parity Check Matrix:
An (n – k) x n matrix H such that: C = {y n | HyT = 0}
Codewords are the nullspace of H
These always exist for linear codes
15-853 Page21
Advantages of Linear Codes
• Encoding is efficient (vector-matrix multiply)
• Error detection is efficient (vector-matrix multiply)
• Syndrome (HyT) has error information
• Gives qn-k sized table for decoding
Useful if n-k is small
15-853 Page22
Example and “Standard Form”
For the Hamming (7,4,3) code:
1 0 0 1 0 1 1
0 1 0 1 0 1 0
G
0 0 1 1 0 0 1
0 0 0 0 1 1 1
By swapping columns 4 and 5 it is in the form Ik,A.
A code with a matrix in this form is systematic, and
G is in “standard form” 1 0 0 0 1 1 1
0 1 0 0 1 1 0
G
0 0 1 0 1 0 1
0 0 0 1 0 1 1
15-853 Page23
Relationship of G and H
If G is in standard form [Ik,A]
then H = [AT,In-k]
transpose
1 0 0 0 1 1 1
1 1 1 0 1 0 0
0 1 0 0 1 1 0
G H 1 1 0 1 0 1 0
0 0 1 0 1 0 1
1 0 1 1 0 0 1
0 0 0 1 0 1 1
15-853 Page24
Proof that H is a Parity Check Matrix
Suppose that x is a message. Then
15-853 Page27
NASA Mariner:
Deep space probes from
1969-1977.
Mariner 10 shown
15-853 Page28
How to find the error locations
HyT is called the syndrome (no error if 0).
In general we can find the error location by creating
a table that maps each syndrome to a set of error
locations.
Theorem: assuming s 2d-1 every syndrome value
corresponds to a unique set of error locations.
Proof: Exercise.
15-853 Page29