Linear Block Codes

Theory

The theory associated with Experiment-1 is divided into two parts:

(1) Preliminaries

(2) Linear block codes

1. Preliminaries

This section will introduce some preliminaries about finite fields, binary arithmetic, and vector spaces that are relevant to Experiment-1. For a detailed discussion of the topics, please refer [1, Ch. 2] and [2, Ch. 1]. We shall discuss the following topics:

  • Introduction to finite fields and binary arithmetic.

  • Vector space spanned by the given set of vectors.

1.1 Introduction to finite fields and binary arithmetic

For all the experiments considered in this virtual lab, we consider vectors and matrices that are defined over a finite field. In order to define a finite field, we need to first define a "binary operation", which is provided next.

Definition 1 (Binary operation): Let F\mathbb{F} be a set of elements. A binary operation \star is a rule that assigns to each pair of elements a,bFa, b \in \mathbb{F} a uniquely defined third element c=abFc = a \star b \in \mathbb{F}.

For example, consider the set of real numbers, denoted by R\mathbb{R}. It can be verified that the addition operation defined for real numbers is a binary operation.

In order to define a field, consider a set F\mathbb{F} on which two binary operations called addition (+)(+) and multiplication ()(\cdot) are defined. For the given {F,+,}\{\mathbb{F}, +, \cdot\},
a definition of the field is given below.

Definition 2 (Field): {F,+,}\{\mathbb{F}, +, \cdot\} is said to be a field if satisfies the following axioms:

  • Associativity of (+)(+) and ()(\cdot): Elements a,b,cFa, b, c \in \mathbb{F} satisfy a+(b+c)=(a+b)+ca + (b + c) = (a + b) + c and a(bc)=(ab)ca \cdot (b \cdot c) = (a \cdot b) \cdot c.

  • Commutativity of (+)(+) and ()(\cdot): Elements a,b,cFa, b, c \in \mathbb{F} satisfy a+b=b+aa + b = b + a and ab=baa \cdot b = b \cdot a.

  • Distributivity of multiplication over addition: Elements a,b,cFa, b, c \in \mathbb{F} satisfy a(b+c)=(ab)+(ac)a \cdot (b + c) = (a \cdot b) + (a \cdot c).

  • Additive identity: There exist an element 0F0 \in \mathbb{F} such that a+0=aa + 0 = a.

  • Multiplicative identity: There exist an element 1F1 \in \mathbb{F} such that a1=aa \cdot 1 = a and 101 \ne 0.

  • Additive inverses: For every aFa \in \mathbb{F}, there exists an element in F\mathbb{F}, denoted by a-a, called the additive inverse of aa, such that a+(a)=0a + (-a) = 0.

  • Multiplicative inverses: For every a0Fa \ne 0 \in \mathbb{F}, there exists an element in F\mathbb{F}, denoted by a1a^{-1} or 1/a1/a, called the multiplicative inverse of aa, such that aa1=1a \cdot a^{-1} = 1.

It can be verified that the set of real numbers R\mathbb{R} along with the addition and multiplication defined over real numbers is a field. However the set of integers alongwith the addition and multiplication defined over integers is not a field, since for integers multiplication inverses are not integers.

Let us now consider an example of a field with finite number of elements. Consider a set F2\mathbb{F}_2 = { 0, 1 } with the addition and multiplication operations for any a,bF2a, b \in \mathbb{F}_2 defined as Equation (1)

0+0=000=00+1=101=01+0=110=0(1)1+1=011=1. \begin{aligned} 0 + 0 = 0 \hspace{1in} 0 \cdot 0 &= 0\\ 0 + 1 = 1 \hspace{1in} 0 \cdot 1 &= 0\\ 1 + 0 = 1 \hspace{1in} 1 \cdot 0 &= 0 \hspace{1in} (1) \\ 1 + 1 = 0 \hspace{1in} 1 \cdot 1 &= 1. \end{aligned}

It can be verified that the set F2\mathbb{F}_2 alongwith the addition and multiplication operations defined in Eq. (1) is a field, since it satisfies the axioms of Definition 2. Such a field with finite number of elements is called as a finite field. For most of the experiments in this virtual lab, we will focus on the binary field F2=0,1\mathbb{F}_2 = {0,1}. We shall study more about finite fields in Experiment-6.

Except for Experiments 6 and 7, we will consider vectors and matrices defined over the binary field F2\mathbb{F}_2. Vectors are denoted by boldface letters and the components of a vector are denoted by lower case letters, e.g. the components of a vector vF2n\mathbf{v} \in \mathbb{F}_2^n are denoted by v=(v1v2vn)\mathbf{v} = \begin{pmatrix}v_1 & v_2 & \ldots & v_n \end{pmatrix}, where each viF2v_i \in \mathbb{F}_2 for i=1,2,,ni = 1, 2, \ldots, n. Vectors can either be considered as row vectors or columns vectors, depending on the context. Matrices are denoted by upper-case letters, e.g. consider a matrix M in F2m×n\mathbb{F}_2^{m \times n} with mm rows and nn columns. The component of the matrix M corresponding to the ithi^{th} row and jthj^{th} column, for 1im1\leq i \leq m and 1jn1\leq j \leq n, is denoted by MijM_{ij}.

We shall next define addition and multiplication operations for vectors and matrices that are defined over F2\mathbb{F}_2:

  • Addition of two vectors: The addition of two vectors v,wF2n\mathbf{v}, \mathbf{w} \in \mathbb{F}_2^n consists of addition of their respective components defined according to Eq. (1), i.e., v+w=[v1v2vn]+[w1w2wn]=[v1+w1v2+w2vn+wn].\begin{aligned} \mathbf{v} + \mathbf{w} = \begin{bmatrix} v_1 \\ v_2 \\ \vdots \\ v_n \end{bmatrix} + \begin{bmatrix} w_1 \\ w_2 \\ \vdots \\ w_n \end{bmatrix} = \begin{bmatrix} v_1 + w_1 \\ v_2 +w_2 \\ \vdots \\ v_n+w_n \end{bmatrix}.\end{aligned}

For example, [101]+[001]=[100]\begin{bmatrix} 1 & 0 & 1\end{bmatrix} + \begin{bmatrix} 0 & 0 & 1\end{bmatrix} = \begin{bmatrix} 1 & 0 & 0\end{bmatrix}.

  • Multiplication of a vector by a scalar: For a vector vF2n\mathbf{v} \in \mathbb{F}_2^n and a scalar aF2a \in \mathbb{F}_2, ava \cdot \mathbf{v} is given by av=a[v1v2vn]=[av1av2avn], \begin{align*} a \cdot \mathbf{v} = a \cdot \begin{bmatrix} v_1 \\ v_2 \\ \vdots \\ v_n \end{bmatrix} = \begin{bmatrix} a \cdot v_1 \\ a \cdot v_2 \\ \vdots \\ a \cdot v_n \end{bmatrix}, \end{align*} where the operation avia \cdot v_i for i=1,2,,ni = 1, 2, \ldots, n is performed according to Eq. (1).

  • Multiplication of a vector and a matrix: For a vector vF2n\mathbf{v} \in \mathbb{F}_2^n and a matrix MF2n×mM \in \mathbb{F}_2^{n \times m}, vM\mathbf{v} \cdot M is given by

    vM=[v1v2vn][M11M12M1mM21M22M2mMn1Mn2Mnm]=[v1M11+v2M12++vnM1mv1M21+v2M22++vnM2mv1Mn1+v2Mn2++vnMnm], \begin{align*} \mathbf{v} \cdot M &= \begin{bmatrix}v_1 & v_2& \ldots& v_n\end{bmatrix} \cdot \begin{bmatrix} M_{11} & M_{12} & \ldots& M_{1m} \\ M_{21} & M_{22} & \ldots& M_{2m} \\ \vdots \\ M_{n1} & M_{n2} & \ldots& M_{nm} \end{bmatrix} \\ &= \begin{bmatrix} v_1 \cdot M_{11} + v_2 \cdot M_{12} + \ldots + v_n \cdot M_{1m} \\ v_1 \cdot M_{21} + v_2 \cdot M_{22} + \ldots + v_n \cdot M_{2m} \\ \vdots \\ v_1 \cdot M_{n1} + v_2 \cdot M_{n2} + \ldots + v_n \cdot M_{nm} \end{bmatrix}, \end{align*} where note that each component wise addition and multiplication is performed according to Eq. (1). Consider the following example.

    [101][001101101011]=[1000]. \begin{align*} \begin{bmatrix}1 & 0& 1\end{bmatrix} \cdot \begin{bmatrix} 0 & 0 & 1& 1 \\ 0 & 1 & 1& 0 \\ 1 & 0 & 1& 1 \end{bmatrix} &= \begin{bmatrix} 1 & 0 & 0 & 0 \end{bmatrix}. \end{align*}

1.2 Vector space spanned by the given set of vectors

In this section, we shall provide preliminaries about vector space spanned the given set of finite number of vectors, subspace of a vector space, linearly independent vectors, basis of a vector space, dimension of a vector space. Towards defining the vector space spanned by the given set of vectors, we first define linear combination of the given set of vectors and scalars.

Definition 3 (Linear combination): The linear combination of the given set of vectors v1,v2,,vmF2n\mathbf{v}_1 , \mathbf{v}_2, \ldots, \mathbf{v}_m \in \mathbb{F}_2^n and the corresponding set of scalars a1,a2,,amF2a_1, a_2, \ldots, a_m \in \mathbb{F}_2 is defined as a vector v\mathbf{v} obtained as v=a1v1+a2v2++amvm. \begin{align*} \mathbf{v} = a_1\mathbf{v}_1 + a_2\mathbf{v}_2+ \ldots + a_m\mathbf{v}_m. \end{align*} For example, the linear combination of v1=[110],v2=[010],v3=[111]F23\mathbf{v}_1 = \begin{bmatrix} 1 & 1 & 0\end{bmatrix}, \mathbf{v}_2 = \begin{bmatrix} 0 & 1 & 0\end{bmatrix}, \mathbf{v}_3 = \begin{bmatrix} 1 & 1 & 1\end{bmatrix} \in \mathbb{F}_2^3 and the corresponding set of scalars a1=0,a2=1,a3=0F2a_1=0, a_2 = 1, a_3 = 0 \in \mathbb{F}_2 is equal to [010]\begin{bmatrix} 0 & 1 & 0\end{bmatrix}. We shall next provide the definition of a vector space spanned by the given set of vectors.

Definition 4 (Vector space spanned the given set of vectors):The vector space VV spanned by the vectors v1,v2,,vmF2n\mathbf{v}_1 , \mathbf{v}_2, \ldots, \mathbf{v}_m \in \mathbb{F}_2^n is defined as V={vF2nv=a1v1+a2v2+...+amvmfor some scalarsa1,a2,...,amF2}.\begin{align*} V =\Big\{ \mathbf{v} \in \mathbb{F}_2^n \Big| \mathbf{v} = a_1\mathbf{v}_1 + a_2\mathbf{v}_2+ ... + a_m\mathbf{v}_m \hspace{0.1cm} \textit{for some scalars} \hspace{0.1cm} a_1, a_2, ..., a_m \in \mathbb{F}_2 \Big\}. \end{align*} This vector space VV is also called as the span of the vectors v1,v2,,vm\mathbf{v}_1 , \mathbf{v}_2, \ldots, \mathbf{v}_m, denoted by V=span{v1,v2,,vm}V = {span} \{\mathbf{v}_1 , \mathbf{v}_2, \ldots, \mathbf{v}_m\}.

Note that a vector space is essentially the set of all possible linear combinations of the given set of vectors. Let us consider some examples for vector spaces.

  • Example-1: It can be verified that F24\mathbb{F}_2^4 is a vector space spanned by the following set of vectors F24=span{e1,e2,e3,e4}=span{[1000],[0100],[0010],[0001]}(2)\begin{align*} \mathbf{F}_2^4 = \hspace{0.05in}{span} \{\mathbf{e}_1 , \mathbf{e}_2, \mathbf{e}_3, \mathbf{e}_4\} = \hspace{0.05in}{span} \left\{ \begin{bmatrix} 1 \\ 0 \\ 0 \\ 0 \end{bmatrix}, \begin{bmatrix} 0 \\ 1 \\ 0 \\ 0 \end{bmatrix}, \begin{bmatrix} 0 \\ 0 \\ 1 \\ 0\end{bmatrix}, \begin{bmatrix} 0 \\ 0 \\ 0 \\ 1 \end{bmatrix} \right\} \hspace{1.4cm} (2) \end{align*}

  • Example-2: For any integer nn, it can be verified that F2n\mathbb{F}_2^n is a vector space.

  • Example-3: The vector space spanned by the vectors v1=[101],v2=[001]\mathbf{v}_1 = \begin{bmatrix} 1 & 0 & 1 \end{bmatrix}, \mathbf{v}_2 = \begin{bmatrix} 0 & 0 & 1 \end{bmatrix} and v3=[010]\mathbf{v}_3 = \begin{bmatrix} 0 & 1 & 0 \end{bmatrix} is given by V=span{v1,v2,v3}={[000],[100],[010],[001],[101],[110],[011],[111]}(3)\begin{align*} V = \hspace{0.05in}{span} \{\mathbf{v}_1 , \mathbf{v}_2, \mathbf{v}_3\} = \left\{ \begin{bmatrix} 0 \\ 0 \\ 0 \end{bmatrix}, \begin{bmatrix} 1 \\ 0 \\ 0 \end{bmatrix}, \begin{bmatrix} 0 \\ 1 \\ 0 \end{bmatrix}, \begin{bmatrix} 0 \\ 0 \\ 1 \end{bmatrix}, \begin{bmatrix} 1 \\ 0 \\ 1 \end{bmatrix}, \begin{bmatrix} 1 \\ 1 \\ 0 \end{bmatrix}, \begin{bmatrix} 0 \\ 1 \\ 1 \end{bmatrix}, \begin{bmatrix} 1 \\ 1 \\ 1 \end{bmatrix} \right\} \hspace{0.3cm} (3) \end{align*} Note that V=F23V = \mathbf{F}_2^3 since it consists of all possible vectors in F23\mathbf{F}_2^3.

  • Example-4: Consider the vector space spanned by
    the vectors v1\mathbf{v}_1 and v2\mathbf{v}_2 defined in Example-3. It is given by W=span{v1,v2}={[000],[101],[001],[100]}(4)\begin{align*} W\hspace{0.3cm} = \hspace{0.3cm}{span}\{\mathbf{v}_1, \mathbf{v}_2\} = \left\{ \begin{bmatrix} 0 \\ 0 \\ 0 \end{bmatrix}, \begin{bmatrix} 1 \\ 0 \\ 1 \end{bmatrix}, \begin{bmatrix} 0 \\ 0 \\ 1 \end{bmatrix}, \begin{bmatrix} 1 \\ 0 \\ 0 \end{bmatrix} \right\} \hspace{3cm} (4) \end{align*}

We shall next define a subspace of a vector space.

Definition 5 (Subspace): A subspace of a vector space is a nonempty subset that satisfies the requirements for a vector space.

For the examples (Example-3 and 4) mentioned above, W=span{v1,v2}W=\hspace{0.001in}{span}\{\mathbf{v}_1, \mathbf{v}_2\} is a subspace of V=span{v1,v2,v3}V=\hspace{0.001in}{span}\{\mathbf{v}_1, \mathbf{v}_2, \mathbf{v}_3\}.

Definition 6 (Linear independence): A given set of vectors v1,v2,,vmF2n\mathbf{v}_1 , \mathbf{v}_2, \ldots, \mathbf{v}_m \in \mathbb{F}_2^n are said to be independent if and only if a1v1+a2v2++amvm=0a_1\mathbf{v}_1 + a_2\mathbf{v}_2+ \ldots + a_m\mathbf{v}_m = \mathbf{0} can happen only when a1=a2==am=0a_1 = a_2 = \ldots = a_m = 0.

For example, it can be verified that the vectors v1=[101],v2=[001]\mathbf{v}_1 = \begin{bmatrix} 1 & 0 & 1 \end{bmatrix}, \mathbf{v}_2 = \begin{bmatrix} 0 & 0 & 1 \end{bmatrix} and v3=[010]\mathbf{v}_3 = \begin{bmatrix} 0 & 1 & 0 \end{bmatrix} are linearly independent since a1v1+a2v2+a3v3a_1\mathbf{v}_1 + a_2\mathbf{v}_2+ a_3\mathbf{v}_3 gives an all-zero vector only when we choose a1=a2=a3=0a_1=a_2=a_3=0. Whereas the vectors v1=[101],v2=[001]\mathbf{v}_1 = \begin{bmatrix} 1 & 0 & 1 \end{bmatrix}, \mathbf{v}_2 = \begin{bmatrix} 0 & 0 & 1 \end{bmatrix} and v3=[100]\mathbf{v}_3 = \begin{bmatrix} 1 & 0 & 0 \end{bmatrix} are linearly dependent since v1+v2+v3=0\mathbf{v}_1 + \mathbf{v}_2+ \mathbf{v}_3 = \mathbf{0}.

Finally, we shall define basis of a vector space and dimension of a vector space.

Definition 7 (Basis of a vector space): A basis for a vector space VV is a set of vectors having two properties at once:

  • The vectors are linearly independent
  • They span the space VV

For example consider the vector space V=F23V = \mathbb{F}_2^3. For this vector space, the set of vectors v1,v2,v3\mathbf{v}_1, \mathbf{v}_2, \mathbf{v}_3 given in Example-3 is a basis. However the set of vectors w1=[100]\mathbf{w}_1 = \begin{bmatrix} 1 & 0 & 0 \end{bmatrix}, w2=[101]\mathbf{w}_2 = \begin{bmatrix} 1 & 0 & 1 \end{bmatrix}, w3=[010]\mathbf{w}_3 = \begin{bmatrix} 0 & 1 & 0 \end{bmatrix}, w4=[111]\mathbf{w}_4 = \begin{bmatrix} 1 & 1 & 1 \end{bmatrix} is not a basis for the vector space F23\mathbb{F}_2^3 since they are not linearly independent. Further, the set of vectors {w1,w2}\{\mathbf{w}_1, \mathbf{w}_2\} is not a basis for F23\mathbb{F}_2^3 since span {w1,w2}F23\{\mathbf{w}_1, \mathbf{w}_2\} \ne \mathbb{F}_2^3.

Note that a basis is not unique. The given vector space can have more that one basis. Can you find one more basis for the vector space F23\mathbb{F}_2^3 (Hint: See Eq (2))? Note that the number of vectors in any two bases will remain the same. This leads to the dimension of a vector space.

Definition 8 (Dimension of a vector space): The dimension of a space is the number of vectors in every basis.

For example, the dimension of the vector space F23\mathbb{F}_2^3 is equal to 33 since the set of vectors v1,v2,v3\mathbf{v}_1, \mathbf{v}_2, \mathbf{v}_3 given in Example-3 is a basis for F23\mathbb{F}_2^3. Dimension of the vector space WW defined in Example-4 is equal to 22 since {v1,v2}\{\mathbf{v}_1, \mathbf{v}_2\} is a basis of the vector space WW.

2. Linear block codes

alt text

Channel codes (or error correcting codes) are used in any digital communication system to provide a reliable communication over a noisy communication channel. Figure 1 shows a part of a digital communication system focusing on the channel encoder-decoder (refer [1, Ch. 1] for a detailed description of a digital communication system). Suppose the transmitter wants to send a bit-stream over a noisy communication channel. A communication channel may corrupt this bit-stream.

To combat these errors introduced by the channel, a channel encoder is used at the transmitter. The channel encoder adds redundant bits to this input bit-stream that help the receiver to recover (decode) the corrupted bit-stream.

In Part-2 of Experiment-1, we shall introduce binary block channel codes, referred to as block codes from now on. We shall provide the definition of block codes and then consider a subclass of block codes, linear block codes, that satisfy the linearity property. We shall introduce two simple yet important families of block codes, repetition (REP) and single parity check (SPC) codes. Through examples of REP and SPC codes, we shall demonstrate how channel codes can be used to combat the errors introduced the noisy communication channel. For a detailed discussion of the topics, please refer [1,3].
In the remaining part, we shall discuss the following topics:

  • Introduction to linear block codes

  • Repetition (REP) codes

  • Single parity check (SPC) codes

2.1 Introduction to linear block codes

Recall that F2n\mathbb{F}_2^n denotes the vector space of all nn-tuples over the finite field F2\mathbb{F}_2. Basics of finite fields and vector spaces are provided in Section 1.

For block codes, the input bit-stream is first divided into vectors of length kk. Thus the input to a channel encoder is a sequence of vectors of length kk, also termed as message sequence. Let mF2k\mathbf{m} \in \mathbb{F}_2^k denotes one such kk-length message vector. To each message m\mathbf{m}, a block encoder assigns a vector vF2n\mathbf{v} \in \mathbb{F}_2^n of length n>kn > k, according to some rule. This vector v\mathbf{v} is termed as the codeword corresponding to message m\mathbf{m}. Suppose there are MM distinct messages. A definition of a block code is given below.

Definition 9 (Block code C(n,M)\mathcal{C}(n, M)): Consider any map (rule) that assigns a codeword vector vF2n\mathbf{v} \in \mathbb{F}_2^n to the given message vector mF2k\mathbf{m} \in \mathbb{F}_2^k, where n>kn > k. Then the set of codewords corresponding to the given set of MM distinct messages is termed as a block code (or a codebook). The parameter nn is called as the length of the code.
In general note that, the map associated with the a block code need not be one-to-one, i.e., the codewords corresponding to distinct messages need not be distinct. However for the purpose of this lab, we shall focus on the maps where there is a one-to-one correspondence between a message and codeword.

Let us consider an example for a block code. Let {[01],[11]}\left \{\begin{bmatrix} 0 & 1\end{bmatrix}, \begin{bmatrix} 1 & 1\end{bmatrix} \right\} be the set of distinct messages that a transmitter wishes to transmit. Consider the map that assigns the vector [0111]\begin{bmatrix} 0 & 1 & 1 & 1 \end{bmatrix} to the message [01]\begin{bmatrix} 0 & 1\end{bmatrix} and the vector [1101]\begin{bmatrix} 1 & 1 & 0 & 1 \end{bmatrix} to the message [11]\begin{bmatrix} 1 & 1\end{bmatrix}. Then the vectors [0111]\begin{bmatrix} 0 & 1 & 1 & 1 \end{bmatrix} and [1101]\begin{bmatrix} 1 & 1 & 0 & 1 \end{bmatrix} are termed as the codewords corresponding to the messages [01]\begin{bmatrix} 0 & 1\end{bmatrix} and [11]\begin{bmatrix} 1 & 1\end{bmatrix} respectively and C(4,2)={[0111],[1101]}\mathcal{C}(4,2) = \left\{\begin{bmatrix} 0 & 1 & 1 & 1 \end{bmatrix},\begin{bmatrix} 1 & 1 & 0 & 1 \end{bmatrix} \right\} is the corresponding codebook or block code.

Note that a binary vector mF2k\mathbf{m} \in \mathbb{F}_2^k can take 2k2^k possible distinct values. For linear block codes, all possible 2k2^k vectors in F2k\mathbb{F}_2^k comprises the set of distinct messages. However, for linear block codes the map assigning messages to codeword cannot be arbitrary. For linear block codes, as the name suggests, this map should be linear, i.e., it should satisfy the property that addition of any two codewords should also be a codeword. A definition of a linear block code is given below.

Definition 10 (Linear block code C(n,k)\mathcal{C}(n,k)): A block code of length nn and 2k2^k codewords is called as a linear block code if and only if its 2k2^k codewords form a kk-dimensional subspace of the vector space F2n\mathbb{F}_2^n. The parameters nn and kk are called as the length and dimension of a linear block code respectively.

Let us consider an example for a linear block code for k=2k=2. For k=2k=2, the set of messages will be {[00],[01],[10],[11]}\left \{\begin{bmatrix} 0 & 0\end{bmatrix}, \begin{bmatrix} 0 & 1\end{bmatrix}, \begin{bmatrix} 1 & 0\end{bmatrix}, \begin{bmatrix} 1 & 1\end{bmatrix} \right\}. Consider the map that assigns codewords {[000],[011],[101],[110]}\left \{\begin{bmatrix} 0 & 0 & 0\end{bmatrix}, \begin{bmatrix} 0 & 1 & 1\end{bmatrix}, \begin{bmatrix} 1 & 0 & 1\end{bmatrix}, \begin{bmatrix} 1 & 1 & 0\end{bmatrix} \right\} to these messages respectively. It can be verified that that this map is a linear and the set of codewords form a 22-dimensional subspace of F23\mathbb{F}_2^3.

We shall next define the Hamming weight of a vector vF2n\mathbf{v} \in \mathbf{F}_2^n and the Hamming distance between any two vectors v1\mathbf{v}_1 and v2\mathbf{v}_2 in F2n\mathbb{F}_2^n. These notions will be used to define the minimum distance of a block code.

Definition 11 (Hamming weight of a vector): The Hamming weight of a vector vF2n\mathbb{v} \in \mathbb{F}_2^n is defined as the number of non-zero components in it.

Definition 12 (Hamming distance dH(v1,v2)d_H(\mathbf{v}_1, \mathbf{v}_2) between vectors v1\mathbf{v}_1 and v2\mathbf{v}_2): The Hamming distance between vectors v1\mathbf{v}_1 and v2\mathbf{v}_2 in F2n\mathbb{F}_2^n is defined as the number of position these two vectors differ from each other.

For example, the Hamming weight of the vector v=[10011]F25\mathbf{v} = \begin{bmatrix} 1 & 0 & 0 & 1 & 1 \end{bmatrix} \in \mathbb{F}_2^5 is equal to 33. For the vectors v1=[10011]andv2=[10000]\mathbf{v}_1 = \begin{bmatrix} 1 & 0 & 0 & 1 & 1 \end{bmatrix} \hspace{0.1cm}{and}\hspace{0.1cm} \mathbf{v}_2 = \begin{bmatrix} 1 & 0 & 0 & 0 & 0 \end{bmatrix}, the Hamming distance dH(v1,v2)=2d_H(\mathbf{v}_1, \mathbf{v}_2) = 2. We shall next define the minimum distance of a block code.

Definition 13 (Minimum distance dmind_{min} of a block code C(n,M)\mathcal{C}(n,M)): The minimum distance dmind_{min} of the given block code is defined as the minimum Hamming distance between any two codewords of the code, i.e., dminmin{dH(v1,v2)suchthatv1,v2C(n,M)}.\begin{align*} \hspace{1in}d_{min} \coloneqq \min \left\{ d_H(\mathbf{v}_1, \mathbf{v}_2) \hspace{0.1in}{ such \hspace{0.1in} that } \hspace{0.1in} \mathbf{v}_1, \mathbf{v}_2 \in \mathcal{C}(n,M) \right\}. \hspace{1in} \end{align*}

For the linear blocks it can be proved that, the minimum distance is equal the minimum Hamming weight of a non-zero codeword. A linear block code of length nn, dimension kk, and minimum distance dmind_{min} is denoted by C(n,k,dmin)\mathcal{C}(n,k, d_{min}).

We shall next discuss two families of linear block codes; repetition and single parity check codes.

2.2 Repetition codes

Repetition codes are one of the simplest yet important class of linear block codes. For repetition codes we have k=1k=1, i.e., a message can either be 00 or 11. For the repetition code of length nn (REP-nn code), as the name suggests, the message to be transmitted is repeated nn times. Thus the codewords corresponding to the messages 00 and 11 are [000]\begin{bmatrix} 0 & 0 & \ldots & 0 \end{bmatrix} and [111]\begin{bmatrix} 1 & 1 & \ldots & 1 \end{bmatrix} respectively. For example, the codewords of REP-55 are given by {[00000],[11111]}\left\{ \begin{bmatrix} 0 & 0 & 0 & 0 & 0 \end{bmatrix}, \begin{bmatrix} 1 & 1 & 1 & 1 & 1 \end{bmatrix}\right\}. Typically the length nn of the repetition code is chosen to be an odd integer since an odd length is suitable for majority logic decoding of repetition codes when the noise is introduced a binary symmetric channel of cross-over probability pp, denoted by BSC(pp). A few preliminaries about the binary symmetric channel are summarized in Remark 1.

Remark 1 (Binary symmetric channel (BSC(pp))): In this remark, we shall describe how noise is modeled according to the binary symmetric channel. As shown in Figure 2 for BSC(pp), a transmitted bit is flipped independently with probability pp.

alt text

Without loss of generality we assume that p<1/2p < 1/2, since when p>1/2p > 1/2, one can first flip the entire received bit sequence and use the decoding algorithms developed for the the case when p<1/2p < 1/2. For example, when a vector [011]\begin{bmatrix} 0 & 1 & 1\end{bmatrix} is transmitted over BSC(p)(p), the probability of receiving the vector [110]\begin{bmatrix} 1 & 1 & 0\end{bmatrix} is equal to p2(1p)p^2(1-p) since the first and the third bits are flipped, whereas the second bit is not flipped. Note that a transmitted vector can get flipped to any vector in F2n\mathbb{F}_2^n.

We shall now describe majority logic decoding for repetition codes of odd lengths. First note that, a transmitted codeword can get flipped to any vector in F2n\mathbb{F}_2^n (see Remark 1). According to majority logic decoding, the received vector yF2n\mathbf{y} \in \mathbb{F}_2^n is decoded as 11 if the number of 11's are in it are in majority, otherwise it is decoded as 00. For example, for REP-33 code, when received vector is y=[110]\mathbf{y} = \begin{bmatrix} 1 & 1 & 0\end{bmatrix}, the decoded message is 11, since the bit is in majority in this y\mathbf{y}.

We shall next illustrate how repetition codes can help to correct some of the errors introduced by the BSC. Suppose the codeword [111]\begin{bmatrix} 1 & 1 & 1\end{bmatrix} is transmitted and the received vector is such that at most one of the bit is flipped. Then according to majority logic decoding, the decoded codeword will be [111]\begin{bmatrix} 1 & 1 & 1\end{bmatrix} and receiver is able to correct such errors. However, note that if more than two bits are flipped then the decoded codeword will be incorrect and receiver is not able to correct such error patterns. In the Experiment-3 we shall see that REP-nn code is able to correct all possible error patterns of weight less than or equal to n12\lfloor \frac{n-1}{2}\rfloor.

2.3 Single parity check codes

For the single parity check (SPC) codes of length nn we have k=n1k=n-1. The codeword corresponding to the message m=[m0m1mn2]F2n1\mathbf{m} = \begin{bmatrix} m_0 & m_1 & \ldots & m_{n-2}\end{bmatrix} \in \mathbf{F}_2^{n-1} is given by v=[m0m1mn2p]\mathbf{v} = \begin{bmatrix} m_0 & m_1 & \ldots & m_{n-2}& p\end{bmatrix}, where p=m0+m1++mn2p = m_0 + m_1 + \ldots + m_{n-2}. For example for (3,2)(3,2) SPC code, the messages and the corresponding codewords are given below:

alt text

Let us now illustrate how SPC codes can be used for detection of some of the error patterns. If v=[v1v2vn]\mathbf{v} = \begin{bmatrix}v_1 & v_2 & \ldots & v_n \end{bmatrix} is a codeword of (n,n1)(n, n-1) SPC then it satisfies the parity check equation given below v1+v2++vn=0.(5)\begin{align*} v_1 + v_2 + \ldots + v_n = 0. \hspace{0.9cm} (5) \end{align*} The property of SPC codes given in Eq. (5) is used to for single bit error detection. Suppose the codeword v=[v1v2vn]\mathbf{v} = \begin{bmatrix}v_1 & v_2 & \ldots & v_n \end{bmatrix} of (n,n1)(n,n-1) SPC code is transmitted and the received vector is such that one of the bit is flipped. Then the received vector will not satisfy the parity check equation of Eq. (5). This will indicate that that an error has occurred. Note that this will not help to identity the location of the error. Eq. (5) will just help us to detect whether one-bit is flipped or not.

Note that Eq. (5) will not be useful if two bits are flipped, since the received vector will satisfy Eq. (5) when exactly two bits are flipped.