Presentation is loading. Please wait.

Presentation is loading. Please wait.

ERROR-DETECTING AND ERROR- CORRECTING CODES ․ A simple scheme for detecting errors is to append a parity check digit to each block of message. Even parity:

Similar presentations


Presentation on theme: "ERROR-DETECTING AND ERROR- CORRECTING CODES ․ A simple scheme for detecting errors is to append a parity check digit to each block of message. Even parity:"— Presentation transcript:

1 ERROR-DETECTING AND ERROR- CORRECTING CODES ․ A simple scheme for detecting errors is to append a parity check digit to each block of message. Even parity: the total number of 1s in a block is even. Thus, for the message BAT, which encoded as will be transmitted as ․ Suppose BAT is received as We know one digit is wrong in the first block.

2 ․ Another error-detecting scheme is to transmit each block twice. For instance, BAT is transmitted as Again, received message is as the following, revealing the 8th digit is incorrect in the 1st block ․ Definition: (1) message word: message block; message length k = 8 (2) code-word: bit string to be transmitted for a message word; code-word length n = 9 (the former), n = 16 (the latter) (3) efficiency of (k,n)-block code, i.e. k/n: 8/9 (the former), 8/16 (the latter)

3 ․編碼 (E)/ 解碼 (D) 函數 : one-to-one function and E = D -1 (inverse func of D), D = E -1 message w1, w2, w3… to be encoded as E(w1), E(w2), E(w3), ….. decoded as D(E(w1)) = w1 if correct, D(E(w2)) = w2, …. Ex31: By transmitting each block 3 times, we get Although efficiency is low (k/n=8/24), it is possible to identify the intended code-word even if transmitted wrongly. The 8th bit is incorrectly received as follows: …., but we assume correct code-word is …. dut to probability.

4 Ex32: 兩字碼如後 : , 若錯誤發生在這兩個 字碼的最後一個位元, 系統不會察覺錯誤已發生 ; 所以欲擁有 錯誤修正能力, 不只要求編 / 解碼函數為一對一函數, 另外還需 下述的論辯. ․ Hamming distance: d(010101, ) = 2 d( , ) = 4 ․ The Triangle Inequality: d(c1, c3) ≤ d(c1, c2) + d(c2, c3) if c1, c2 and c3 are code-words of the same length. 接收到一字碼 c, 系統解碼成 D(c) ; 但, 接收到不是字碼的 c’ 碼, 系統還是會解碼成 D(c), 如果只有 d(c,c’) 最小. 如果有兩個以 上的字碼一樣的最靠近 c’, 則系統記錄有錯誤發生 ; 接收到不是 字碼的 z 碼, 若 D(z) 沒有定義 ( 例如雜訊 ), 系統應記錄 : 錯誤發生

5 ․假設一編碼系統的字碼距離都至少為 3, 且接收到不是字碼的 c’ 碼 ; 如果已知傳送時發生單一錯誤, 設 d(c6, c’) = 1, 則 code- word c6 必為原先所傳輸的字碼. Suppose a code-word c7≠ c6 ; with the Triangle Inequality, 3 ≤ d(c6, c7) ≤ d(c’, c6) + d(c’, c7) = 1 + d(c’, c7)  2 ≤ d(c’, c7) 但, 已知傳送時只發生單一錯誤 ; 故, c7 不可能為原先傳輸的字碼. Theorem: The min Hamming distance of a block code is m, then the sys (1) can detect r or fewer errors if and only if m ≥ r + 1 (2) can correct r or fewer errors if and only if m ≥ 2r + 1 ․好的編碼 -- 修正區塊中儘可能多的錯誤 -- 其字碼間的最小距離 須愈大愈好

6 MATRIX CODES ․ Define W m to be the set of all strings of 0s and 1s with length m. For example, W 3 = {000, 001, 010, 011, 100, 101, 110, 111} the encoding func for a (k, n)-block code is a one-to-one func E: W k → W n. Suppose A is a kxn matrix of 1s and 0s, and x is a 1xn matrix of 1s and 0s. The product x A over Z 2 is a 1xn matrix of 1s and 0s. Hence, an element in W m can be regarded as a 1xm matrix of 1s and 0s, and then the product of an element x in W k and matrix A is the element xA in W n. Ex33: Let and x = [1 1 0], y = [0 1 0] x A = [ ] is an element of W 4 yA = [ ]

7 ․ E defines a matrix code: when E is one-to-one and E: W k → W n defined by E(x) = x A A: generator matrix ․ To ensure that E is one-to-one is to choose the first k columns of A form the kxk identity matrix I k. Denote A having this form by writing A = [ I k | J ], where J is a kx(n-k) matrix whose columns are the last n-k columns of A. For such matrix A, the first k entries of xA will be the same as in x. Hence, if x 1 A = x 2 A then x 1 = x 2. Ex34: then

8 ․前述的生成矩陣 A 為 3x7 矩陣, 其對應的矩陣碼為 (3,7)- 區塊碼 ; 對任何 W 3 中元素, [w1 w2 w3], 可得 [w1 w2 w3]A = [w1 w2 w3 w1 w2 w3 w1+w2+w3] i.e. 對訊息字元 w 而言, 其對應字碼, E( w ) = w A, 是重複 w 兩次 再加上其同位位元 ; 編碼如下 : E([0 0 0]) = [ ] = c1 E([0 0 1]) = [ ] = c2 : E([1 1 1]) = [ ] = c8 Please note d(c1, c2) = 3, d(c1, c8) = 8 …, so it can detect 2 bits error and correct one bit error according to the theorem above.

9 The Check Matrix of a Code ․ Define a nx(n-k) matrix A* so that its first k rows are the corresponding rows of J and its last n-k rows are those of the (n-k)x(n-k) identity matrix. Symbolically, we write and is called the check matrix associated with A. Ex35:   is not coincident!

10 Theorem: A = [ I k | J ] be the generator matrix for a (k, n)-block code, and let A* be its check matrix. (1) In the kx(n-k) matrix AA*, each entry equals 0. (2) A word c of length n is a code-word iif cA* = 0 (a 1x(n-k) zero matrix) Ex36: ( ref ex34) For x = [ ], its we have xA = [ ] Because xA ≠0, theorem implies x is not a codeword. Ex37: Justify the condition that [w1 w2 w3 w4 w5 w6 w7]A* = [ ] Since [w1 w2 w3 w4 w5 w6 w7]A* = [w1+w4 w2+w5 w3+w6 w1+w2+w3+w7]

11 ․ We get w1 = -w4, i.e. w1= w4 (over Z 2 ) then w2 = w5, w3 = w6, and w1 + w2 + w3 = -w7 = w7 Hence, w7 = 0 if [w1 w2 w3] contains an even number of 1s, and w7 = 1 if [w1 w2 w3] contains an odd number of 1s. ․ Thus [w1 w2 w3 w4 w5 w6 w7]A* = [ ] when [w4 w5 w6] is identical to [w1 w2 w3], and w7 is a check bit of 1 or 0 according to whether the number of 1s in [w1 w2 w3] is even or odd. But these are exactly the requirements that make x A* a codeword for this code.

12 MATRIX CODES THAT CORRECT ALL SINGLE-DIGIT ERRORS Theorem: A code can correct all single-bit errors iif its check matrix satisfies the following two conditions: (1) No row of A* consists entirely of 0s. (2) No two row of A* are identical. Ex38: (ref ex35) The codeword corresponding to the message word x = [1 0 1] is xA = [ ]. Because this is a (3, 7)-block code, the first 3 bits are the original message word. Similarly, the codeword [ ] decodes as [0 1 1].

13 Note: In step 1, the w A* is named as syndrome of w.

14 Ex39: Decode the message which was sent using the code in ex 35. The decoding of this message, using the check matrix row decoding method, is shown in the following table: Since the syndrome of the last word is nonzero, but not a row of A*, there must have been 2 or more errors in the transmission. Received word w Syndrome w A* Row of A* not a row of A* Codeword unknown Message word unknown

15 Hamming Code ․回憶 ex37 的 (3, 7)- 碼, 能夠修正所有單一位元錯誤, 其效率為 3/7 ; 似乎不夠好, 不禁要問 : 能夠修正所有單一位元錯誤且最有 效率的 (3, n)- 碼 為何 ? P. 51 的定理透露端倪, 如果 n=3 則每個收到的字元皆為字碼 ; 因而無法偵測到傳輸錯誤. 假設 A = [ I k | J ] 是 (3, 4)- 碼 的生成 矩陣, 則 J 為 3x1 矩陣, 會有兩相同列 ; 所以 A* 有兩個相同的列, 故無法修正所有單一位元錯誤. 設 A = [ I k | J ] 是 (3, 5)- 碼 的生成矩陣, 則 J 為 3x2 矩陣, 會有兩相 同列 ; 所以 A* 無法修正所有單一位元錯誤. 然而, 若 A 是 (3, 6)- 碼 的生成矩陣, 則 J 為 3x3 矩陣, 很容易找到 A*, 例如, 故 (3, 6)- 碼 可以修正所有單一位元錯誤.

16 Theorem: A (k, n)-code exists that corrects all single-bit errors iif 2 n-k – 1 ≥ n. Setting r = n – k, n = 2 r – 1 i.e. n is 1 less than a power of 2. We require r > 1 because r = 1 implies that k = 0 (wrong!) The first five such values of k and n are given in the following: For these pairs of k and n, we can construct a (k, n)-code that corrects all single-bit errors. The check matrix, which is nxr, has n rows, each of length r. But there are only 2 r such rows for A*, so each nonzero row must be used. A matrix code for which the check matrix has this property is called a Hamming code. r k = 2 r – r n = 2 r

17 Ex40: The preceding table shows that the Hamming code for r = 2 has k = 1 and n = 3. Thus the check matrix is  since the rows of A* must be nonzero and distinct, so ? must be 1. In this case, for every message word [x] we have [x]A = [x x x] and so the code repeats each message word three times. The decoding of each possible word that can be received is given in the following: Word received syndrome row of A* codewordMessage word

18 Suppose we have a Hamming code, and a word c’ is received. The syndrome of c’ is s = c’A*. If s ≠ 0, then s appears as a row of A* because every nonzero word of length r appears as a row of A*. Let row i of A* equal s. Then c’ will be decoded as the first k bits of c, where c is the word obtained by changing the ith bit of c’. Thus when check matrix row decoding is used, step 4 never happens, and every received word can be decoded. The efficiency of the Hamming code for a particular value of r is and Thus there are Hamming codes with efficiencies that is close to 1.


Download ppt "ERROR-DETECTING AND ERROR- CORRECTING CODES ․ A simple scheme for detecting errors is to append a parity check digit to each block of message. Even parity:"

Similar presentations


Ads by Google