Σημειωσεισ Εργaστηριο Θεωρια Πληροφοριασ-κωδικεσ
-
Upload
andy-poulos -
Category
Documents
-
view
24 -
download
6
description
Transcript of Σημειωσεισ Εργaστηριο Θεωρια Πληροφοριασ-κωδικεσ
-
(...)
: -
.
2006
-
1
: MATLAB 1: 2: bit BPSK 3: bit BPSK 4: , Gauus (AWGN ) 5: 6: Hamming (n,k) 7: , Hamming (n,k) 8: (n,k) 9: BCH -- 10: Reed-Solomon -- 11: Hamming
-
2
- ... . . (hardware), , ( MATLAB).
(information theory) , , ( ) . , Claude Shannon 13 1000 . Claude Shannon 1948 , .
, , . E, .
.
..
-
3
: MATLAB
MATLAB (http://www.mathworks.com/products/matlab). MATLAB (MATrix LABoratory) , , , , . - MATLAB, .
MATLAB, intro prompt MATLAB
MATLAB :
Help Help plot
plot
y x. .. :
x=[-3 1 0 1 3 ]; y=x.*x-3*x ; plot(x,y) z=x+y*sqrt(-1) ; plot(z)
editor MATLAB (FileNewmfile,
bin MATLAB .. program.m) script program.m
echo off:
()
plot(x, y), grid on : . (label) () x y
:
xlabel('megethos toy aksona x'); ylabel(''megethos toy aksona y');
:
-
4
pause % Press a key to see.
x ( y) :
semilogx(x, y)
, w:
w=[1:10,12:2:100,105:5:500, 510:10:5000,5025:25:20000,20050:50:100000];
(Pinakas) ( ):
Pinakas=[1 1 0 1 0 0 0; 0 1 1 0 1 0 0; 1 1 1 0 0 1 0; 1 0 1 0 0 0 1]
..: title('Titlos ths grafikhs parastashs')
(Comment) % (: %..). . Comment
: Run ( F5)
Command Window MATLAB
fig .. .fig
, MATLAB 6.0 .
-
5
1
1.1
(entropy) .
1.2
( ). , H , [1-3]:
=
= i
n
ii p
1logpH 21
(1.1)
(1.1), n pi i.
. p, (1-p). (1.1), :
( )
+
=p-1
1log1p1logH 22 pp (1.2)
. (1.1) ( ) n , [2].
1.3
MATLAB . . . p .
function H=Entropy(p) echo off p=[0:0.1:1]; for i=1:11 H(i)=-p(i)*log2(p(i))-(1-p(i))*log2(1-p(i));
-
6
End pause % Press a key to see a plot of entropy versus probability of binary alphabet clf plot(p, H), grid on; xlabel('Probability p of the binary symbol'); ylabel('Binary Entropy H ');
echo off. , , p , 0 1. , p . :
p=[0:0.1:1]; (1.3)
p
. p 0.1. p, ( x y).
p , . :
H(i)=-p(i)*log2(p(i))-(1-p(i))*log2(1-p(i)); (1.4)
p,
0.1 0 1, p. (loop). O , p 0.1, . H p. :
for i=1:11 H(i)=-p(i)*log2(p(i))-(1-p(i))*log2(1-p(i)); (1.5) End : pause % Press a key to see a plot of entropy versus probability of binary alphabet(1.6) p .
-
7
p, plot(x,y):
plot(p, H), grid on; (1.6)
, MATLAB (grid on) .
, (label) () x y :
xlabel('Probability p of the binary symbol');
ylabel('Binary Entropy H '); (1.7)
, MATLAB, [4], 1.1.
1.1 (Binary entropy, H)
p (Probablity of the binary symbol, p)( MATLAB).
. 1.4 1. p . 2. 0.2, 0.3, 0.5.
-
8
2
bit BPSK
2.1
BPSK bit .
2.2
(channel capacity) , [5]. , , (probability of error) , [6-9]. C ( bits/sec) R (bits/sec) , :
CR < (2.1)
, . , . (attenuation), (linear and non-linear distortion) .. , (noise), (multipath fading) .., [5]. , . , . (Discrete Memoryless Channel, DMC) ( ) , ( ) (channel transition probability matrix) ( )yxp , Xx Yy . , (Binary Symmetric Channel, BSC). , 0 1,
}1 ,0{== YX ( ) ( ) p0110 ====== xypxyp ( ) (crossover probability). , 2.1.
-
9
2.1 (BSC).
, : ( )pH-1C = (2.2) p (crossover probability) () H (p) . BPSK, p bit b (noise spectral density) Gauss (Additive White Gaussian Noise, AWGN) N0 (energy per bit per N0), [5,10], :
( ) ( )212p erfcQ == (2.3)
(2.3), erfc(x) (Error Function), [5,10,11], Q(x) ():
( ) dzeQ zx
2
2
21x
= (2.4) (2.3) Q(x) erfc(x):
( ) ( )2
xx2 erfcQ = (2.5)
N0, AWGN (Watt/Hz) . Gauss , ( ) Gauss ( ), [10].
0 1
0 1
1-p
1-p
p
p
-
10
2.3
MATLAB
=0N
Eb
bit b N0. echo off gamma_db=[-20:1:20]; gamma=10.^(gamma_db/10); for i=1:41 e(i)=0.5*erfc(sqrt(gamma(i))); H(i)=-log2(e(i))*(e(i))-log2(1-e(i))*(1-e(i)); c(i)=1-H(i); end pause % Press a key to see a plot of channel capacity versus SNR/bit clf semilogx(gamma, c), grid on; xlabel ('Energy per bit per noise spectral efficiency for BPSK'); ylabel('Channel Capacity of BSC for BPSK modulation');
=0N
Eb .
dB, 20dB 20dB 1 ( ). :
gamma_db=[-20:1:20]; (2.6)
, . dB : gamma=10.^(gamma_db/10); (2.7) :
( ) 10(dB)10 = (2.8)
(2.3), p, . A : e(i)=0.5*erfc(sqrt(gamma(i))); (2.9)
p e. MATLAB erfc(x).
:
-
11
H(i)=-log2(e(i))*(e(i))-log2(1-e(i))*(1-e(i)); (2.10) (1.2). C : c(i)=1-H(i); (2.11)
C. ( 41 (i=1:41).
H (press) : pause % Press a key to see a plot of channel capacity versus SNR/bit (2.12)
H
, :
xlabel('Energy per bit per noise spectral efficiency for BPSK'); ylabel('Channel Capacity of BSC for BPSK modulation'); (2.13) x : semilogx(gamma, c), grid on; (2.14)
, , MATLAB (grid on) .
, MATLAB, 2.1.
-
12
2.1
( bit ) ( MATLAB) BPSK .
2.4
1. , .
2. MATLAB p (bit) (crossover probability) 10 p . ; .
-
13
3
bit
BPSK 3.1
, (Bit Error Rate, BER)
=0N
Eb , bit b
N0. , Gauss (Additive White Gaussian Noise, AWGN). 3.2
, p (crossover probability) (bit) (Signal-to Noise Ratio, SNR) ( ). BPSK ( ) , [5, 11]:
( )
===
0BPSK 2
12pBERNEerfcQ b (3.1)
=0N
Eb Eb (bit)
N0 , (bit ). 3.3
MATLAB
=0N
Eb
bit b N0. gamma_db=[-50:0.1:50]; gamma=10.^(gamma_db./10); err=0.5*erfc(sqrt(gamma)); clf semilogx(gamma_db,err), grid on; xlabel ('Energy per bit per noise spectral density for BSC-BPSK'); ylabel ('BER of BPSK');
-
14
=0N
Eb . dB,
50dB 50dB 0.1 ( ). :
gamma_db=[-50:0.1:50]; (3.2)
dB, : gamma=10.^(gamma_db./10); (3.3) H ( ) (BER) ( err) : err=0.5*erfc(sqrt(gamma)); (3.4)
H :
xlabel('Energy per bit per noise spectral density for BSC-BPSK');
ylabel('BER of BPSK'); (3.5) , x : semilogx(gamma, c), grid on; (3.6)
, , MATLAB (grid on) .
-
15
3.1 (BER) (BSC)
bit BPSK ( MATLAB).
3.4
1. , bit 0dB;
2. MATLAB DPSK. BERDPSK, p, DPSK, [5,11]:
021pBER DPSK
NEb
e== (3.7)
3. 0N
Eb
BPSK.
-
16
4
, Gauss 4.1
(bandlimited channel) (Signal-to-Noise Ratio) . , , Gauss AWGN. 4.2
, , ( ) AWGN , [10]. 0, P W C.Shannon, [6,7], C ( bits/sec) :
+= WNP1logWC
02 (4.1)
, 0N
P ,
C ( bits/sec). , W, C
0N
P ,
, [5,11]:
000
2WW NP1.4427
ln2NP
WNP1logWlimClim ==
+= (4.2) .
-
17
4.3
1. MATLAB C W=3000Hz
0N
P ( 0N
P 20 30dB)( (4.1).
2. MATLAB
C 0N
P 25dB
W. echo on pn0_db=[-20:0.1:30]; pn0=10.^(pn0_db./10); capacity=3000.*log2(1+pn0/3000); pause % Press a key to see a plot of channel capacity versus P/N0 clf semilogx(pn0, capacity) title('Capacity vs P/N0 in an AWGN channel') xlabel('P/No'); ylabel('Channel Capacity (bits/second)'); clear w=[1:10,12:2:100,105:5:500, 510:10:5000,5025:25:20000,20050:50:100000]; pn0_db=25; pn0=10.^(pn0_db./10); capacity=w.*log2(1+pn0./w); pause % Press a key to see a plot of channel capacity versus bandwith clf semilogx(w, capacity), grid on; title('Capacity vs bandwidth in an AWGN channel') xlabel('Bandwidth (Hz)'); ylabel('Channel Capacity (bits/second)');
0N
P :
pn0_db=[-20:0.1:30]; (4.3)
-
18
pn0_db 20 30 dB ( ). , pn0_db (4.1)
0NP
:
pn0=10.^(pn0_db./10); (4.4)
(capacity) W=3000Hz, : capacity=3000.*log2(1+pn0/3000); (4.5)
(4.1).
(pause % Press a key to see a plot of channel capacity versus P/N0) C AWGN ( bits/sec)
0NP
W=3000Hz ( 4.1). x : semilogx(pn0, capacity) (4.6)
( 4.1) (title) : title('Capacity vs P/N0 in an AWGN channel') (4.7)
x y, :
xlabel('P/No'); ylabel('Channel Capacity (bits/second)'); (4.8)
,
0. : Clear (4.9)
C AWGN W . W :
w=[1:10,12:2:100,105:5:500, 510:10:5000,5025:25:20000,20050:50:100000]; (4.10)
:
0NP =25dB.
0N
P
(4.1): pn0_db=25; (4.11)
-
19
pn0=10.^(pn0_db./10);
C :
capacity=w.*log2(1+pn0./w); (4.12)
(pause % Press a key to see a plot of channel capacity versus bandwith) ( 4.2). x (label) (title) :
semilogx(w, capacity), grid on; title('Capacity vs bandwidth in an AWGN channel') (4.13)
xlabel('Bandwidth (Hz)');
ylabel('Channel Capacity (bits/second)');
4.1 (channel capacity) ( bits/sec) AWGN
0N
P (
) W=3000Hz ( MATLAB).
-
20
4.2 (channel capacity) AWGN ( bits/sec)
(Bandwidth) ( Hz)
0NP =25dB (
MATLAB). 4.4
1. AWGN
5000 Hz 0N
P=25dB;
2. AWGN 0N
P =30 dB
W=3000 Hz; 3. , ,
MATLAB:
echo off w=[1:5:20,25:20:100,130:50:300,400:100:1000,1250:250:5000,5500:500:10000]; pn0_db=[-20:1:30]; pn0=10.^(pn0_db./10); for i=1:45 for j=1:51 c(i,j)=w(i)*log2(1+pn0(j)/w(i)); end end echo on k=[0.9,0.8,0.5,0.6]; s=[-70,35];
-
21
surfl(w,pn0_db,c',s, k) title('capacity vs.bandwidth and SNR')
4. (4.2) (
ex
x
x=
+
11 lim ).
-
22
5
5.1
MATLAB (error probability, Pe) bit (simple repetition codes). 5.2
(errors) (bit). () (noiseless). bits (transmission rate). bits (coding). : , (block) (convolutional) , [1,2].
, ( ), k ( ) (codewords) n
nk , [1]. (n,k)
2k ( ) n,
kccc 221 ,..., . ,
(encoder) ( ) k , [1,2,5].
, , , k0 n0, k0 (L-1) k0 , [1,2,5].
(simple repetition code). 0 1 (BSC), 0 1, 0 1 0 1. (odd) n. , :
-
23
876
876
11...111
00...000n
n
(5.1)
(decoding)
: ( ) , 0 bit 0. , 1 bit 1.
, (n+1)/2 bit . BSC , (crossover probability) bit , (n,k) , [4,5,11]:
( ) knknnk
e kn
p
+=
= 1
2/)1(
(5.2)
, n=5 =0.001=10-3,
:
( ) 910553
101099.9999.0001.05
==
= kk
ke k
p (5.3)
(5.3), 5 bits
, 0.001(=10-3) 10-9. . , , 1 bit 1 bit 5 . , , . pe n. , n=9, , (5.2):
( ) 1516995
101097.9999.0001.09
==
= kk
ke k
p (5.4)
,
, (n) . C. Shannon , [6,7], , ( )0ep , , .
-
24
5.3
MATLAB bit , bit =0.3 pe ( ) (block-length)(n). n 1 61. echo off ep=0.3; for i=1:2:61 p(i)=0; For j=(i+1)/2:i p(i)=p(i)+prod(1:i)/(prod(1:j)*prod(1/i-j)))*ep^j*(1-ep)^(i-j); end end stem((1:2:61),p(1:2:61)) xlabel(n) ylabel(pe) title(Error probability as a function of n in simple repetition code)
pe (5.2) :
( ) knknnk
knkn
nke k
nkn
p +=
+=
=
= 7.03.03.013.0
2/)1(2/)1(
(5.5)
ep: ep=0.3; (5.6)
n, i. i 1 61, : for i=1:2:61 (5.7)
2.
(5.5), p(i) pe n. , p(i) :
p(i)=0; (5.8)
-
25
. ( n k)
)!(!!
knkn
kn
=
MATLAB : prod(1:i)/(prod(1:j)*prod(1:(i-j))) (5.9)
( i n j k) n! MATLAB: n!=i!=prod(1:i) (5.10)
(
). pe n n (5.5). pe, n 1 61, : stem((1:2:61),p(1:2:61)) (5.10)
( )( ).
, (label) x y (title) :
xlabel('n') ylabel('pe') (5.11)
title('Error probability as a function of n in simple repetition code')
5.1 pe (Error probability)
n ( MATLAB).
-
26
5.4
1. n pe; 2. MATLAB
n=7. 3.
0.05, =0.3; , ;
4. 0.05, =0.1; MATLAB. , ;
5. (5.2).
-
27
6
Hamming (n,k)
6.1
MATLAB Hamming (n,k) . 6.2 6.2.1
. , , [1,5,9]. , (generator matrix) G, ( nk ) c :
uGc = (6.1) u k ()( ). modulo-2 ( XOR). , , ( Hamming) Hamming , [11].
mind , [11]: ( )jiHji ccdd ,minmin = (6.2)
, Hamming wmin (minimum weigth, wH) :
( )iHC cww i 0min min= (6.3) (weigth, wH) , ( wH 1 ). (systematic form) G :
G=
p . . .p p
p . . .p p p . . .p p
k,n-kk,k,
,n-k,,
,n-k,,
21
22212
12111
1 ..... 0 0
0 .... 1 0 0 .... 0 1
(6.4)
G=[Ik | P] (6.5) (6.5) Ik , (kk) (identity matrix) P k(n-k) . ,
-
28
k bits bits () (n-k) bits bits (parity-check bits).
(parity check matrix) H (n-k)n , c :
cHt= 0 (6.6) Ht (transpose matrix) H ( ).
: GHt= 0 (6.7)
G : =[-Pt|In-k] (6.8) ( () : 1=-1). 6.2.2 Hamming
Hamming (2m-1, 2m-m-1) 3 . m(2m-1) , m, . , m=3 (7,4) , , :
H=
1 0 0 1 1 1 0 0 1 0 1 0 1 1
0 0 1 1 1 0 1 (6.9)
(6.5) ( (6.8))
G :
G=
1 1 1 1 0 0 01 0 1 0 1 0 0 1 1 0 0 0 1 0
0 1 1 0 0 0 1
(6.10)
( G=[I4 | P]. 6.3
MATLAB Hamming m=3 (n,k)=(7,4) Hamming. G , :
G=
1 0 0 0 1 0 10 1 0 0 1 1 1
0 0 1 0 1 1 00 0 0 1 0 1 1
(6.11)
-
29
MATLAB k=4 bits:[1 0 1 1]. n=7; k=4; genmat=[1 1 0 1 0 0 0; 0 1 1 0 1 0 0; 1 1 1 0 0 1 0; 1 0 1 0 0 0 1] parmat=hammgen(3) msg= [1 0 1 1]; code=encode(msg, n, k, 'hamming') msg' code'
, MATLAB Hamming . Hamming :
n=7; k=4; (6.12)
, hammgen . G :
G=[P | Ik=4 ] (6.13)
MATLAB G :
genmat=[1 1 0 1 0 0 0; 0 1 1 0 1 0 0; 1 1 1 0 0 1 0; 1 0 1 0 0 0 1] (6.14)
hammgen
H (parmat) : H=[ In-k | -Pt ]= =[ I3 | -Pt] (6.15)
G (6.13). : parmat=hammgen(3) (6.16) H:
parmat=
1 1 1 0 1 0 0 0 1 1 1 0 1 0
1 1 0 1 0 0 1 (6.17)
, msg (message), k=4 , :
-
30
msg= [1 0 1 1]; (6.18) H , : code=encode(msg, n, k, 'hamming') (6.19) MATLAB Hamming.
: Code=[ 1 0 0 1 0 1 1] (6.20)
4 bits ,
bits 3 bits bits (parity-check bits).
MATLAB :
n=7; k=4; genmat=[1 1 0 1 0 0 0; 0 1 1 0 1 0 0; 1 1 1 0 0 1 0; 1 0 1 0 0 0 1] genmat = 1 1 0 1 0 0 0 0 1 1 0 1 0 0 1 1 1 0 0 1 0 1 0 1 0 0 0 1 parmat=hammgen(3) parmat = 1 0 0 1 0 1 1 0 1 0 1 1 1 0 0 0 1 0 1 1 1 msg= [1 0 1 1]; code=encode(msg, n, k, 'hamming') code = 1 0 0 1 0 1 1
-
31
msg' ans = 1 0 1 1 code' ans = 1 0 0 1 0 1 1
6.4
1. [ 0 0 1 0].
2. Hamming (15,11). bits ; bits ; MATLAB G :
G=[P | I11 ] (6.21)
P :
P=
1 1 1 1 1 0 1 1
1 1 0 11 1 1 0 0 1 1 11 0 1 01 0 0 10 1 0 1 1 1 0 0
0 1 1 01 0 1 1
(6.22)
-
32
7
, Hamming (n,k)
7.1
Hamming (n,k) . , (detection) (correction) (single error) . 7.2
Hamming (n,k). H G. H : =[-Pt| Ik] (7.1) G : G=[Ik | P] (7.2)
. , bit bits bits .
(vector table) 0 1 . (syndrome table) S . . , R H () S. H. .. (2) 2 bit R. RHt=S (7.3)
(CorrectedCodeword) R modulo-2 ( ) S. :
CorrectedCodeword= SR (7.4)
,
(decoding table)
-
33
. Hamming .
7.3 n=7; k=4; % the parameters of the Hamming code parmat=[1 1 1 0 1 0 0; 1 1 0 1 0 1 0; 1 0 1 1 0 0 1] % parity-check matrix genmat=gen2par(parmat) % find the Generator matrix from the parity-check matrix msg=[1 0 0 0];% message code=encode(msg, n, k, 'hamming') % coding with Hamming code (n,k) trt=syndtable(parmat) % Produce decoding table recd=[1 1 0 1 1 1 0] % the received codeword syndrome=rem(recd*parmat', 2) % syndrome in binary syndrome_de=bi2de(syndrome, 'left-msb'); % Convert to decimal corrvect=trt(1+syndrome_de,:) correctdcode=rem(corrvect+recd,2) % find the corrected codeword msg'; code';
, Hamming:
n=7; k=4; % the parameters of the Hamming code (7.5)
, (parmat) :
H=
1 0 0 1 1 0 1 0 1 0 1 0 1 1
0 0 1 0 1 1 1 (7.6)
: parmat=[1 1 1 0 1 0 0; 1 1 0 1 0 1 0; 1 0 1 1 0 0 1] % parity-check matrix (7.7)
G :
genmat=gen2par(parmat) % find the Generator matrix from the parity-check matrix (7.8) :
genmat=
1 1 0 1 0 0 01 0 1 0 1 0 0
0 1 1 0 0 1 01 1 1 0 0 0 1
(7.9)
-
34
[1 0 0 0] 4 bits: msg=[1 0 0 0]; % message (7.10) () encode MATLAB Hamming : code=encode(msg, n, k, 'hamming') % coding with Hamming code (n,k) (7.11) : code=1 1 0 1 0 0 0 (7.12)
(trt) syntable MATLAB: trt=syndtable(parmat) % Produce decoding table (7.13) (parmat) :
trt=
0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
(7.14)
(recd)
recd=[1 1 0 1 1 1 0]. (syndrome) ( ) (7.3) :
syndrome=rem(recd*parmat', 2) % syndrome in binary (7.15) recd t modulo 2 ( 2). (syndrome) :
syndrome = (7.16)
1 0 0
(decimal). MATAB bi2de, :
-
35
syndrome_de=bi2de(syndrome, 'left-msb'); % Convert to decimal (7.17)
MATLAB : n=7; k=4; % the parameters of the Hamming code parmat=[1 1 1 0 1 0 0; 1 1 0 1 0 1 0; 1 0 1 1 0 0 1] % parity-check matrix parmat = 1 1 1 0 1 0 0 1 1 0 1 0 1 0 1 0 1 1 0 0 1 genmat=gen2par(parmat) % find the Generator matrix from the parity-check matrix genmat = 1 0 0 0 1 1 1 0 1 0 0 1 1 0 0 0 1 0 1 0 1 0 0 0 1 0 1 1 msg=[1 0 0 0]; % message code=encode(msg, n, k, 'hamming') % coding with Hamming code (n,k) code = 1 1 0 1 0 0 0 trt=syndtable(parmat) % Produce decoding table trt = 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 recd=[1 1 0 1 1 1 0] % the received codeword
-
36
recd = 1 1 0 1 1 1 0 syndrome=rem(recd*parmat', 2) ; % syndrome in binary syndrome = 1 0 0 syndrome_de=bi2de(syndrome, 'left-msb'); % Convert to decimal corrvect=trt(1+syndrome_de,:) corrvect = 0 0 0 0 1 0 0 correctdcode=rem(corrvect+recd,2) ; % find the corrected codeword correctdcode = 1 1 0 1 0 1 0 msg'; code'; 7.4
1. . :
recd=[1 1 1 1 1 1 1] recd=[0 0 0 0 0 0 0] recd=[0 1 0 1 0 1 0]
2. ,
, ;
-
37
8
(n,k) 8.1
() (cyclic code) (n,k) . (n,k) . 8.2
(cyclic shift) ,[11]. G (generator polynomial). , [ ]0121 ... ccccC nn = [ ]1032 ... nnn cccc .
, [ ]0121 ... ccccC nn = ( )pC 1 n , : ( ) 012211 ... cpcpcpcpC nnnn ++++= (8.1)
(8.1) :
( ) pcpcpcpcppC nnnn 021121 ... ++++= (8.2) (8.2) 1+np , :
( ) ( )11
11 ++=+ nnn p
pCcp
ppC (8.3)
( ) 102123121 ... +++++= nnnnn cpcpcpcpcpC (8.4)
( )pC1 ( )ppC 1+np :
( ) ( ) ( )1 mod 1 += npppCpC (8.5)
(n,k),
( )pg (n-k). (n,k) , :
( ) 1... 111 ++++= pgpgppg knknkn (8.6)
-
38
(message
polynomial) : ( ) 012211 ... xpxpxpxpX kkkk +++= (8.7)
[ ]0121 ... xxxx kk k bits (). ( ) ( )pgpX (n-1) . n=7 ( bits ). To 17 +p : ( ) ( ) ( )1111 3237 +++++=+ pppppp (8.8)
(n,k), :
( ) ( )1231 ++= pppg (8.9)
( ) ( )132 ++= pppg (8.10)
,
. , [0001] [1110] ( ) ( )1231 ++= pppg [0001101] [1000110].
+ modulo 2 ( , EXOR, Exclusive OR). , .. p3+p3=0.
(n,k). G , :
G=[Ik| P] (8.11)
, H (n,k),
: =[In-k |Pt] (8.12)
8.3 n=15; k=5; genpoly = cyclpoly(15,5) [parmat,genmat] = cyclgen(15, cyclpoly(15,5)) msg=[0 0 0 1 1]; code=encode(msg, n, k, 'cyclic', genpoly) newmsg=decode(code,n,k, 'cyclic', genpoly)
-
39
code1=[1 1 1 1 0 0 1] newmsg=decode(code1,n,k, 'cyclic', genpoly)
, , n k. :
n=15; k=5; (8.13)
k n bits .
, genpoly, : genpoly = cyclpoly(15,5) (8.14)
: genpoly = cyclpoly(n,k) (8.15)
(15,5) ,
: genpoly = 1 0 0 0 0 1 0 0 0 0 1 (8.16)
MATLAB . :
( ) 1051 xxpg ++= (8.17)
G H . MATLAB () cyclgen. , :
[parmat,genmat] = cyclgen(15, cyclpoly(15,5)) (8.18)
: cyclgenn(n, cyclpoly(n,k)) (8.19) parmat genmat :
-
40
parmat = Columns 1 through 13 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 Columns 14 through 15 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0
0 1 genmat = Columns 1 through 13 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 Columns 14 through 15 0 0 0 0 0 0 1 0 0 1
(515) (kn) (1015) ((n-k)n).
(msg) k=5 [0 0 0 1 1] :
-
41
msg=[0 0 0 1 1]; (8.20) : code=encode(msg, n, k, 'cyclic', genpoly) (8.21)
H : code = 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 15 bits (n=15).
(decoding) :
newmsg=decode(code,n,k, 'cyclic', genpoly) (8.22)
(code) , (newmsg): newmsg = 0 0 0 1 1
(code1), 15 bits:
code1=[1 1 1 1 0 0 1 0 1 1 1 1 1 1 0]
: newmsg=decode(code1,n,k, 'cyclic', genpoly) (8.23) (newmsg) :
-
42
newmsg = 1 1 1 1 0 5 bits.
MATLAB :
-
43
n=15; k=5; genpoly = cyclpoly(15,5) genpoly = 1 0 0 0 0 1 0 0 0 0 1 [parmat,genmat] = cyclgen(15, cyclpoly(15,5)) parmat = Columns 1 through 13 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 Columns 14 through 15 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0 1 genmat = Columns 1 through 13 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 Columns 14 through 15 0 0 0 0 0 0 1 0
-
44
0 1 msg=[0 0 0 1 1]; code=encode(msg, n, k, 'cyclic', genpoly) code = 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 newmsg=decode(code,n,k, 'cyclic', genpoly) Single-error patterns loaded in decoding table. 1008 rows remaining. 2-error patterns loaded. 918 rows remaining. 3-error patterns loaded. 648 rows remaining. 4-error patterns loaded. 243 rows remaining. 5-error patterns loaded. 0 rows remaining. newmsg = 0 0 0 1 1 code1=[1 1 1 1 0 0 1 0 1 1 1 1 1 1 0] code1 = Columns 1 through 13 1 1 1 1 0 0 1 0 1 1 1 1 1 Columns 14 through 15 1 0 newmsg=decode(code1,n,k, 'cyclic', genpoly) Single-error patterns loaded in decoding table. 1008 rows remaining.
-
45
2-error patterns loaded. 918 rows remaining. 3-error patterns loaded. 648 rows remaining. 4-error patterns loaded. 243 rows remaining. 5-error patterns loaded. 0 rows remaining. newmsg = 1 1 1 1 0 8.4 1. (21,7).
MATLAB. ;
2. MATLAB [1 0 1 0] (15,4).
3. (7,4) [0 1 0 1 0 1 0], MATLAB . ;
4. (7,3). MATLAB. ; ;
-
46
9
BCH -- 9.1
BCH . BCH (noise) . 9.2
BCH (Bose-Chaudhuri-Hocquenghem) . BCH 1959-1960 , [15,16]. ( k/n), n k (encoders) .
BCH (n,k) (n k ) n k , [11,12]:
(9.3) 12(9.2) (9.1) 12
min +=
=
tdmtkn
n m
m ( 3m ) t . To dmin Hamming (minimum Hamming distance) t, t . n BCH (9.1) ( ) : 2/)12( < mt (9.4) , . BCH (factors) 112 +mp . BCH Reed-Solomon . (n,k) BCH , k Galois, [14-16]. Galois (Galois field) () . Galois, m2 m 1 16. Galois GF( m2 ).
-
47
Galois - (error-control coding). , BCH , (row) Galois, BCH.
BCH, k n. n k. n k, [11].
, BCH . (cellular mobile telephony systems) BCH (shortened BCH code) (signaling messages) (mobile unit), , .
9.3 1 n=15; k=5; % the parameters of the BCH code msg = [1 0 0 1 0] % one message with k=5 bits length gp= bchpoly (15, 5) % generation of the polynomial generator for the BCH code c = encode(msg, n, k, 'bch',gp) % encoding the message 1
BCH , n k :
n=15; k=5; % the parameters of the BCH code (9.5)
. k=5, (msg) bits 5, BCH.
BCH, , . . , ( gp) :
gp= bchpoly (15, 5) % generation of the polynomial generator for the BCH code (9.6) : = = bchpoly (15, 5) (9.7)
, (msg) : c = encode(msg, n, k, 'bch',gp) % encoding the message (9.8)
-
48
c. 1 >> n=15; k=5; msg = [1 0 0 1 0] msg = 1 0 0 1 0 gp= bchpoly (15, 5) gp = 1 1 1 0 1 1 0 0 1 0 1 c = encode(msg, n, k, 'bch',gp) c = 1 0 0 0 0 1 1 1 0 1 1 0 0 1 0 >>
-
49
2 n=15; k=5; % the parameters of the BCH code dat=randint(1,k) % one random message with length k bits genpoly=bchpoly(n,k); % generation of the generator polynomial for BCH code msg = gf(dat); % Galois field c1=encode(dat, n,k, 'bch', genpoly) % encoding the dat with the (n,k) BCH code t=2 % assuming t errors in each codeword noise=randerr(1,n,t) % production of random noise codeword_noisy=rem(c1+noise',2)% received codeword with noise(XOR beetween arrays) dec_message=decode(codeword_noisy,n,k,'bch',genpoly) % decoding the codeword with noise 2
, BCH n k. :
n=15; k=5; % the parameters of the BCH code (9.9)
MATLAB, . :
dat=randint(1,k) % one random message with length k bits (9.10)
(random) , k bits, bits . l k bits, : dat=randint(l,k) (9.11)
, BCH . : genpoly=bchpoly(n,k); % generation of the generator polynomial for BCH code (9.12) CH. , MATLAB BCH . : msg = gf(dat); % Galois field (9.13) (msg) Galois. (dat) : c1=encode(dat, n,k, 'bch', genpoly) % encoding the dat with the (n,k) BCH code (9.14)
t ( ), :
t=2 % assuming t errors in each codeword (9.15)
-
50
E, , (noise) n (=15) 1: noise=randerr(1,n,t) % production of random noise (9.16) , ( ) ( ) : codeword_noisy=rem(c1+noise',2)% received codeword with noise (XOR beetween arrays) (9.17)
, (codeword_noisy)
decode, : dec_message=decode(codeword_noisy,n,k,'bch',genpoly) %decoding the codeword with noise (9.18) (dec_message). >> n=15; k=5; dat=randint(1,k) % one message with length k bits dat = 0 1 0 1 0 genpoly=bchpoly(n,k); % generation of the generator polynomial for BCH code msg = gf(dat); % Galois field c1=encode(dat, n,k, 'bch', genpoly) % encoding with BCH code c1 = 0 0 0 1 1 1 0 1 1 0 0 1 0 1
-
51
0 t=2 % t errors in each codeword t = 2 noise=randerr(1,n,t) % addittion of noise noise = Columns 1 through 13 0 1 0 0 1 0 0 0 0 0 0 0 0 Columns 14 through 15 0 0 codeword_noisy=rem(c1+noise',2) % XOR between Arrays codeword_noisy = 0 1 0 1 0 1 0 1 1 0 0 1 0 1 0 dec_message=decode(codeword_noisy,n,k,'bch',genpoly) % decoding process dec_message = 0 1 0 1 0 >>
-
52
9.4 1. BCH (31,26). 2. BCH (15,7); 3. [100110] BCH (31,6).
-
53
10
Reed-Solomon -- 10.1
Reed-Solomon, [15]. , MATLAB Reed-Solomon . , Reed-Solomon, (random noise) . 10.2
Reed-Solomon 1960 Reed Solomon, [15]. (non binary codes) (bursts errors) CD (Compact Disk) (compact disk audio technology).
Reed-Solomon, 2m { }12 ..., 2, 1, ,0 m .
n ( ) ( - ) 2m-1 ( 3 2m-1). 2m 2m+1 . e0 n . k ( ) ( n (n-k) ) bits (parity symbols) e0 (n-k)=n-2e0= 2m-1. m bits/, 3 16. , Reed-Solomon 2/)( knt = (error-correction capability of the code). Reed-Solomon dmin=(n-k+1) . 10.3 1 echo off n=7; k=3; m=3; msg=gf([1 6 4; 0 4 3], m); c=rsenc(msg,n,k) 1
echo off. Reed-Solomon n k
-
54
. m=3 bits :
msg=gf([1 6 4; 0 4 3],m); (10.1)
k=3 Galois (gf). ( rsenc) msg. . Galois () n=7 2^(3)=8 . (primitive polynomial). 1 c = GF(2^3) array. Primitive polynomial = D^3+D+1 (11 decimal) Array elements = 1 6 4 4 3 6 3 0 4 3 3 7 4 7 2 echo off m=3; % number of bits per symbol n=2^m-1; % codeword length k=3; % message length t=(n-k)/2; % error correcting capability of the code nw=5; % number of word to process msgw=gf(randint(nw,k,2^m),m); % random k-symbol messages c=rsenc(msgw,n,k) % coding the message "msgw" d=rsdec(c,n,k) % decoding the message "msgw" noise =(1+randint(nw,n,2^m-1)).*randerr(nw,n,t); % t errors/row cnoisy = c +noise % codeword with noise [dc,nerrs,corrcode] = rsdec(cnoisy,n,k); % decoding process isequal(dc,msgw) & isequal(corrcode, c) % the decoder can correct t errors/row noise1=(1+randint(nw,n,2^m-1)).*randerr(nw,n,t+1); % add more than t errors/row ((t+1) eroors/row) cnoisy1 = c +noise1 % new codeword with "noise1" [dc,nerrs,corrcode] = rsdec(cnoisy1,n,k); % decoding the "cnoisy1" codeword isequal(dc,msgw) & isequal(corrcode, c) % the decoder can not correct t+1 errors 2
, Reed-Solomon :
m=3; % number of bits per symbol n=2^m-1; % codeword length (10.2)
k=3; % message length
-
55
t=(n-k)/2;% error correcting capability of the code t Reed-Solomon . (number of words) (nw) : nw=5; % number of word to process (10.3)
:
msgw=gf(randint(nw,k,2^m),m); % random k-symbol messages (10.4) k=3 ( 3 bits ) 8 .H Reed-Solomon :
c=rsenc(msgw,n,k) % coding the message "msgw" (10.5)
(c).
, , c d: d=rsdec(c,n,k) % decoding the message "msgw" (10.6)
(
) . :
noise =(1+randint(nw,n,2^m-1)).*randerr(nw,n,t); % t errors/row (10.7)
cnoisy = c +noise % codeword with noise (10.8)
(noise) c ( ) ( ) cnoisy t=2 . : [dc,nerrs,corrcode] = rsdec(cnoisy,n,k); % decoding process noise (10.9)
:
isequal(dc,msgw) & isequal(corrcode, c) % the decoder can correct t errors/row (10.10) (dc) (corrcode). t=2 2 , (10.10) 1. (t+1) , (noise1):
-
56
noise1=(1+randint(nw,n,2^m-1)).*randerr(nw,n,t+1);%add more than t errors/row ((t+1) eroors/row (10.11) : [dc,nerrs,corrcode]=rsdec(cnoisy1,n,k); % decoding the "cnoisy1" codeword (10.12)
( ) Reed-Solomon t . :
isequal(dc,msgw) & isequal(corrcode, c)% the decoder can not correct t+1 errors (10.13)
0. 2 >> c = GF(2^3) array. Primitive polynomial = D^3+D+1 (11 decimal) Array elements = 1 4 3 5 6 2 0 5 7 1 1 3 7 3 2 7 1 5 4 3 0 7 2 4 0 1 6 5 1 3 5 5 7 3 7 d = GF(2^3) array. Primitive polynomial = D^3+D+1 (11 decimal) Array elements = 1 4 3 5 7 1 2 7 1 7 2 4 1 3 5 cnoisy = GF(2^3) array. Primitive polynomial = D^3+D+1 (11 decimal) Array elements = 2 4 3 5 6 2 3 5 7 1 7 3 5 3 2 7 0 5 7 3 0 0 2 4 0 1 6 1
-
57
1 3 4 3 7 3 7 ans = 1 cnoisy1 = GF(2^3) array. Primitive polynomial = D^3+D+1 (11 decimal) Array elements = 1 4 3 0 1 2 4 5 0 5 1 3 1 3 0 1 1 5 7 3 0 3 1 4 0 1 7 5 1 3 5 0 7 7 3 ans = 0 >> 10.4 1. MATLAB
Reed-Solomon :
bits/ : 5
: 9
N k. ;
2. MATLAB: echo on
m=4; n=2^m-1;
k=11; t=(n-k)/2;
nw=7; msgw=gf(randint(nw,k,2^m),m);
c=rsenc(msgw,n,k noise =(1+randint(nw,n,2^m-1)).*randerr(nw,n,t+3);
cnoisy = c +noise d=rsdec(c,n,k)
[dc,nerrs,corrcode] = rsdec(cnoisy,n,k); isequal(dc,msgw) & isequal(corrcode, c)
,
-
58
11
Hamming
11.1
MATLAB Hamming , (orthogonal signaling) (antipodal signaling). (soft-decision decoding) (hard-decision decoding).
11.2
0 + 1 . , , 0 0 1 +.
, .
, dE (minimum Euclidean distance) . dmin, , , , [11,12]:
=
,2
,
min
min
Ed
Edd E (11.1)
(11.1), (bit) .
(n,k) , n (bits) nE k bits , bit Eb :
c
b RE
knEE == (11.2)
(11.2), Rc ( ) (rate) k/n ( bits , bits ).
pe () ( ) (message errror) , :
-
59
( )
021
NdQMp
E
e (11.3)
(11.3), =2k ( k bits ) 0 . (11.3) (11.1) (11.2) :
( )
( )
,1
, 2
1
0
min
0
min
NERd
QM
NERd
QM
pbc
bc
e (11.4)
(11.4)
0NEb
b = . , ,
pe ( ) :
( ) ( )[ ] 2min141 de ppMp (11.5)
, (11.5), p bit ( 0 1) ( BSC )(crossover probalility). bit , :
=
=
= ,
22
,
00
00
NER
QN
EQ
NER
QNEQ
pbc
bc
(11.6)
11.3 1. MATLAB Hamming (15,11) (orthogonal signaling)
0NEb
b = ( b 0 15dB). :
-
60
( ) ( )2
2 yerfcyQ = (11.7) echo off gamma_b_db=[0:0.1:15]; % Energy per bit/No in dB (b in dB) gamma_b=10.^(gamma_b_db/10); q=(1/2).*erfc(0.6*sqrt(gamma_b)); % orthogonal signaling q1=(4*q).*(1-q) p_err=2047*(q1.^(3/2)); loglog(gamma_b,p_err) xlabel ('Energy per bit per No') ylabel ('Symbol error for a Hamming code (15,11) (HD-orthogonal signaling)')
, echo off. ( )
0NEb
b = bit : gamma_b_db=[0:0.1:15]; % Energy per bit/No in dB (b in dB) (11.8)
O 0N
Ebb = :
gamma_b=10.^(gamma_b_db/10); (11.9)
, (11.5) (11.6) . :
q=(1/2).*erfc(0.6*sqrt(gamma_b)); % orthogonal signaling (11.10)
q1=(4*q).*(1-q) (11.11)
p_err=2047*(q1.^(3/2)); (11.12)
(11.7) ( )yQ
( )yerfc ( 0.6 (11.11)). , Rc=k/n=11/15=0.733.
, , .
-
61
11.1 (symbol error)
Hamming (15,11)
, 0N
Eb bit
( MATLAB).
11.4
1. MATLAB
Hamming (15,11) (antipodal signaling)
0NEb
b = ( b 0 15dB). (11.7).
2. MATLAB Hamming (15,11)
0NEb
b = ( b 0 15dB). (11.7).
3. MATLAB Hamming (15,11)
-
62
0N
Ebb = ( b 0 15dB).
(11.7).
-
63
[1] T.Cover and J.Thomas, Elements of Information Theory, New York: Wiley, 1991. [2] .., , II,
Shannon , , 1981. [3] .., , , , 1994. [4] J.G.Proakis and M.Salehi, Contemporary Communication Systems Using MATLAB,
PWS, Publishing Company, 1998. [5] J.G. Proakis, Digital Communications, 3rd Edit., McGraw-Hill, 1995. [6] C.E.Shannon, "A mathematical theory of communication", Bell System Tech. Journal,
pp. 17-28, July 1948. [7] C.E.Shannon, "Communication in the presence of noise", Proc. of the IRE, vol. 37, pp.
10-21, Jan. 1949. [8] C.E.Shannon and W.Weaver, A Mathematical Theory of Communication, Urbana, IL:
Univ. Illinois Press, 1949. [9] R.G.Gallager, "Information Theory and Reliable Communication", John Wiley & Sons,
1968. [10] ., , 1986. [11] J.G.Proakis, M.Salehi, M: ., ., .,
., , ...., 2002. [12] R.Ziemer, R.Peterson, Introduction to Digital Communication, Mcmillan, 1992. [13] H.P.Hsu, , Schaum, :
., , 2002. [14] S.Lin and D.J.Costelo, Jr., Error Control Coding:Fundamentals and Applications,
Prentice Hall, 1983. [15] I.S.Reed and G.Solomon, "Polynomial Codes over Certain Finite Fields", Journal of
the Society for Industrial and Applied Mathematics, June 1960.