Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna,...

35
Information and Information and Coding Theory Coding Theory Linear Block Codes. Linear Block Codes. Basic definitions and some examples. Basic definitions and some examples. Juris Viksna, 201

Transcript of Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna,...

Page 1: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

Information and Information and Coding TheoryCoding Theory

Linear Block Codes. Linear Block Codes. Basic definitions and some examples. Basic definitions and some examples.

Juris Viksna, 2015

Page 2: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

Transmission over noisy channel

Page 3: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

Transmission over noisy channel

Page 4: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

Noisy channel

In practice channels are always noisy (sometimes this could be ignored).There are several types of noisy channels one can consider.We will restrict attention to binary symmetric channels.

Page 5: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

Shannon Channel Coding Theorem

Page 6: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

Shannon Channel Coding Theorem

Page 7: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

Codes – how to define them?In most cases it would be natural to use binary block codes that maps input vectors of length k to output vectors of length n.

For example: 101101 11100111110011 01000101etc.

Thus we can define code as an injective mapping from vector space V with dimension k to vector space W with dimension n.

Such definition essentially is used in the original Shanon’s theorem.

V W

Page 8: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

Codes – how to define them?We can define code as an injective mapping from “vector space” V with dimension k to “vector space” W with dimension n.

Arbitrary mappings between vector spaces are hard either to explicitly define or to use (encode ort decode) in practice (there are almost 2n2k of them – already around 1000000000000000000000000000000 for k=4 and n=7).

Simpler to define and use are linear codes that can be defined by multiplication with matrix of size kn (called generator matrix).

0110

0110011

Shanon’s results hold also for linear codes.

Page 9: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

Codes – how to define them?Simpler to define and use are linear codes that can be defined by multiplication with matrix of size kn (called generator matrix).

What should be the elements ofvector spaces V and W?

In principle in most cases it will be sufficient to have just 0-s and 1-s,however, to define vector space in principle we need a field – an algebraic system with operations “+” and “” defined and having similar properties as we have in ordinary arithmetic (think of real numbers).

Field with just “0” and “1” may look very simple, but it turns out that to get some real progress we will need more complicated fields, just that elements of these fields themselves will be regarded as (most often) binary vectors.

Page 10: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

What are good codes?Linear codes can be defined by their generator matrix of size kn .

Shanon’s theorem tells us that for a transmission channel with a bit errorprobability p and for an arbitrary small bit error probability pb we wish to achieve there exists codes with rates R = k/n that allows us to achieve pb as long as R<C(p).

In general, however, the error rate could be different for different codewords, pb being an “average” value.

We however will consider codes that are guaranteed to correct up to t errors for any of codewords.

Page 11: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

What are good codes?We however will consider codes that are guaranteed to correct up to t errors for any of codewords – this is equivalent with minimum distance between codewords being d and t = d1/2.

Such codes will then be characterized by 3 parameters and will be referred to as (n,k,d) codes.

For a given k we are thus interested:- to minimize n- to maximize d

In most cases for fixed values n and k the larger values of d will give uslower bit error probability pb, although the computation of pb is not that straightforward and depends from a particular code.

Note that one can completely “spoil” d value of good code with low pb by including in it a vector with weight 1

Page 12: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

Vector spaces - definitionWhat we usually understand by vectors?

In principle we can say that vectors are n-tuples of the form:(x1,x2,,xn)

and operations of vector addition and multiplication by scalar are defined and have the following properties:

(x1,x2,,xn)+(y1,y2,,yn)=(x+y1,x+y2,,x+yn)a(x1,x2,,xn)=(ax1,ax2,,axn)

The requirements actually are a bit stronger – elements a and xi should come from some field F.

We might be able to live with such a definition, but then we will link a vector space to a unique and fixed basis and often this will be technically very inconvenient.

Page 13: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

Vector spaces - definitionDefinition4-tuple (V,F,+,) is a vector space if (V,+) is a commutative group with identity element 0 and for all u,vV and all a,bF:

1) a(u+v)=au+av2) (a+b)v=av+bv3) a(bv)=(ab)v4) 1v=v

Usually we will represent vectors as n-tuples of the form (x1,x2,,xn), however such representations will not be unique and will depend from a particular basis of vector space, which we will chose to use (but 0 will always be represented as n-tuple of zeroes (0,0,,0)).

Page 14: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

Groups - definitionConsider set G and binary operator +.

DefinitionPair (G,+) is a group, if there is eG such that for all a,b,cG:

1) a+bG2) (a+b)+c = a+(b+c)3) a+e = a and e+a = a4) there exists inv(a) such that a+ inv(a)= e and inv(a)+a = e5) if additionally a+b = b+a, group is commutative (Abelian)

If group operation is denoted by “+” then e is usually denoted by 0 andinv(a) by a.If group operation is denoted by “” hen e is usually denoted by 1 andinv(a) by a1 (and ab are usually written as ab).It is easy to show that e and inv(a) are unique.

Page 15: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

Vector spaces – dot (scalar) productLet V be a k-dimensional vector space over field F. Let b1,,bkV be some basis of V. For a pair of vectors u,vV, such that u=a1b1+...+akbk and v=c1b1+...+ckbk their dot (scalar) product is defined by:

u·v = a1·c1 +...+ ak·ck

Thus operator “” maps VV to F.

LemmaFor u,v,wV and all a,bF the following properties hold:

1) u·v = v·u.2) (au+bv)·w = a(u·v)+b(v·w).3) If u·v = 0 for all v in V, then u = 0.

Page 16: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

Vector spaces – dot (scalar) product

Let V be a k-dimensional vector space over field F. Let b1,,bkV be some basis of V. For a pair of vectors u,vV, such that u=a1b1+...+akbk and v=c1b1+...+ckbk their dot (scalar) product is defined by:

u·v = a1·c1 +...+ ak·ck

Two vectors u and v are said to be orthogonal if u·v = 0. If C is a subspace of V then it is easy to see that the set of all vectors in V that are orthogonal to each vector in C is a subspace, which is called the space orthogonal to C and denoted by C.

Page 17: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

Linear block codes

Message source

Encoder ReceiverDecoderChannel

x = x1,...,xk

messagex' estimate ofmessage

y = c + ereceived vector

e = e1,...,en

error from noise

c = c1,...,cn

codeword

Generally we will define linear codes as vector spaces – by taking C to be a k-dimensional subspace of some n-dimensional space V.

Page 18: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

Linear block codesLet V be an n-dimensional vector space over a finite field F.

DefinitionA code is any subset CV.

DefinitionA linear (n,k) code is any k-dimensional subspace C⊑V.

Page 19: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

Linear block codesLet V be an n-dimensional vector space over a finite field F.

DefinitionA linear (n,k) code is any k-dimensional subspace C⊑V.

Example (choices of bases for V and code C):

Basis of V (fixed): 001,010,100Set of V elements: {000,001,010,011,100,101,110,111}Set of C elements: {000,001,010,011}2 alternative basesfor code C: 001,010

001,011

Essentially, we will be ready to consider alternative bases, but will stick to “main one” for representation of V elements.

Page 20: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

Linear block codesDefinitionA linear (n,k) code is any k-dimensional subspace C⊑V.

DefinitionThe weight wt(v) of a vector vV is a number of nonzero components of v in its representation as a linear combination v = a1b1+...+anbn.

Definition The distance d(v,w) between vectors v,wV is a number of distinct components of these vectors.

DefinitionThe minimum weight of code C⊑V is defined as minvC,v0 wt(v).

A linear (n,k) code with minimum weight d is often referred to as (n,k,d) code.

Page 21: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

Linear block codesTheoremLinear (n,k,d) code can correct any number of errors not exceeding t = (d1)/2.

ProofThe distance between any two codewords is at least d.

So, if the number of errors is smaller than d/2 then the closestcodeword to the received vector will be the transmitted one

However a far less obvious problem: how to find which codeword is the closest to received vector?

Page 22: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

LInear codes - the main problem

A good (n,k,d) code has small n, large k and large d.

The main coding theory problem is to optimize one of the parameters n, k, d for given values of the other two.

Page 23: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

Generator matricesDefinition

Consider (n,k) code C⊑V. G is a generator matrix of code C, if

C = {vG | vV} and all rows of G are independent.

It is easy to see that generator matrix exists for any code – take any matrix G rows of which are vectors v1,,vk (represented as n-tuples in the initially agreed basis of V) that form a basis of C. By definition G will be a matrix of size kn.

Obviously there can be many different generator matrices for a given code. For example, these are two alternative generator matrices for the same (4,3) code:

1100

1010

1001

1G

0101

1111

1100

2G

Page 24: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

Equivalence of codesDefinition

Codes C1,C2⊑V. are equivalent, if a generator matrix G2 of C2 can be obtained from a generator matrix G1 of C1 by a sequence of the following operations:1) permutation of rows2) multiplication of a row by a non-zero scalar3) addition of one row to another4) permutation of columns5)multiplication of a column by a non-zero scalar (not needed for binary)

Note that operations 1-3 actually doesn’t change the code C1. Applying operations 4 and 5 C1 could be changed to a different subspace of V, however the weight distribution of code vectors remains the same.

In particular, if C1 is (n,k,d) code so is C2. In binary case vectors of C1 and C2 would differ only by permutation of positions.

Page 25: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

Generator matricesDefinition

A generator matrix G of (n,k) code C⊑V is said to be in standard form if G = (I,A), where I is kk identity matrix.

Theorem

For code C⊑V there is an equivalent code C that has a generator matrix in standard form.

Page 26: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

Hamming code [7,4]

Parity bits of H(7,4)

No errors - all pi-s correspond to di-sError in d1,...,d3 - a pair of wrong pi-sError in d4 - all pairs of pi-s are wrongError in pi - this will differ from error insome of di-sSo:- we can correct any single error- since this is unambiguous, we should be able to detect any 2 errors

Page 27: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

Hamming code [7,4]

a = 0001111, b = 0110011 and c = 1010101

H - parity check matrix

Why it does work? We can check that without errors yH = 000and that with 1 error yH gives the index of damaged bit...

General case: there always exists matrix for checking orthogonalityyH = 0. Finding of damaged bits however isn’t that simple.

Page 28: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

Hamming codesFor simplicity we will consider codes over binary fields, although the definition (and design idea) easily extends to codes over arbitrary finite fields.

Definition

For a given positive integer r a Hemming code Ham(r) is code a parity check of which as its rows contains all possible non-zero r-dimensional

binary vectors.

There are 2r 1 such vectors, thus parity check matrix has size 2r 1r

and respectively Ham(r) is (n = 2r 1,n r) code.

Page 29: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

Hamming codesDefinition

For a given positive integer r a Hemming code Ham(r) is code a parity check of which as its rows contains all possible non-zero r-dimensional

binary vectors.

Example of Hamming code Ham(4):

Also not required by definition, note that in this particular case columns can be regarded as consecutive integers 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 written in binary form.

101010101010101

110011001100110

111100001111000

111111110000000

H

Page 30: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

Dual codesDefinition

Consider code C⊑V. A dual or orthogonal code of C is defined as

C = {vV | wC: vw = 0}.

It is easy check that C ⊑V, i.e. C is a code. Note that actually this is just a re-statement of definition of orthogonal vector spaces we have already seen.

There are codes that are self-dual, i.e. C = C.

Page 31: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

Dual codes - some examplesFor the (n,1) -repetition code C, with the generator matrix

G = (1 1 … 1)

the dual code C is (n, n1) code with the generator matrix G, described by:

1...0001

..

0...0101

0...0011

G

Page 32: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

Dual codes - some examples

[Adapted from V.Pless]

Page 33: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

Dual codes - some examples

[Adapted from V.Pless]

Page 34: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

Dual codes – parity checking matricesDefinition

Let code C⊑V and let C be its dual code. A generator matrix H of C is called a parity checking matrix of C.

Theorem

If kn generator matrix of code C⊑V is in standard form if G = (I,A) then (kn)n matrix H = (AT,I) is a parity checking matrix of C.

Proof

It is easy to check that any row of G is orthogonal to any row of H (each dot product is a sum of only two non-zero scalars with opposite signs).

Since dim C + dim C = dim V, i.e. k + dim C = n we have to conclude that H is a generator matrix of C.

Note that in binary vector spaces H = (AT,I) = (AT,I).

Page 35: Information and Coding Theory Linear Block Codes. Basic definitions and some examples. Juris Viksna, 2015.

Dual codes – parity checking matricesTheorem

If kn generator matrix of code C⊑V is in standard form if G = (I,A) then (kn)n matrix H = (AT,I) is a parity checking matrix of C.

So, up to the equivalence of codes we have an easy way to obtain a parity check matrix H from a generator matrix G in standard form and vice versa.

Example of generator and parity check matrices in standard form:

1100100

0110010

0011001

G

1000100

0100110

0010011

0001001

H