diff options
author | priyanka | 2015-06-24 15:03:17 +0530 |
---|---|---|
committer | priyanka | 2015-06-24 15:03:17 +0530 |
commit | b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch) | |
tree | ab291cffc65280e58ac82470ba63fbcca7805165 /1895/CH11 | |
download | Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.gz Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.bz2 Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.zip |
initial commit / add all books
Diffstat (limited to '1895/CH11')
30 files changed, 752 insertions, 0 deletions
diff --git a/1895/CH11/EX11.1/EXAMPLE11_1.SCE b/1895/CH11/EX11.1/EXAMPLE11_1.SCE new file mode 100755 index 000000000..d60e79a05 --- /dev/null +++ b/1895/CH11/EX11.1/EXAMPLE11_1.SCE @@ -0,0 +1,25 @@ +//ANALOG AND DIGITAL COMMUNICATION
+//BY Dr.SANJAY SHARMA
+//CHAPTER 11
+//Information Theory
+clear all;
+clc;
+printf("EXAMPLE 11.1(PAGENO 488)");
+//given
+
+Px_1=1/2;//probability 1
+Px_2=1/4;//probability 2
+Px_3=1/8;//probability 3
+Px_4=1/8;//probability 4
+
+//calculations
+Ix_1 = log2(1/(Px_1))//information content in first probability
+Ix_2 = log2(1/(Px_2))//information content in first probability
+Ix_3 = log2(1/(Px_3))//information content in first probability
+Ix_4 = log2(1/(Px_3))//information content in first probability
+
+//results
+printf("\n\ni. Information content of first symbol = %.2f bit",Ix_1);
+printf("\n\nii. Information content of second symbol = %.2f bits",Ix_2);
+printf("\n\niii. Information content of third symbol = %.2f bits",Ix_3);
+printf("\n\niV. Information content of fourth symbol = %.2f bits",Ix_4);
diff --git a/1895/CH11/EX11.12/EXAMPLE11_12.SCE b/1895/CH11/EX11.12/EXAMPLE11_12.SCE new file mode 100755 index 000000000..72dbff7ea --- /dev/null +++ b/1895/CH11/EX11.12/EXAMPLE11_12.SCE @@ -0,0 +1,24 @@ +//ANALOG AND DIGITAL COMMUNICATION
+//BY Dr.SANJAY SHARMA
+//CHAPTER 11
+//Information Theory
+clear all;
+clc;
+printf("EXAMPLE 11.12(PAGENO 495)");
+//given
+n = 2*10^6//elements od black and white TV picture
+m = 16//brightness levels of black and white TV picture
+o = 32//repeated rate of pictures per second
+
+//calculations
+Px_i = 1/m//probability of brightness levels of picture
+H_X = 0;
+for i= 1:16
+ H_Xi = (-1/(1/Px_i))*log2(1/(1/Px_i));
+ H_X = H_X +H_Xi;
+end
+ r = n*o//rate of symbols generated
+ R = r*H_X//average rate of information convyed
+
+ //results
+printf("\n\ni. Average rate of information convyed = %.2f bits/seconds",R)
diff --git a/1895/CH11/EX11.13/EXAMPLE11_13.SCE b/1895/CH11/EX11.13/EXAMPLE11_13.SCE new file mode 100755 index 000000000..9bd1a5cfa --- /dev/null +++ b/1895/CH11/EX11.13/EXAMPLE11_13.SCE @@ -0,0 +1,24 @@ +//ANALOG AND DIGITAL COMMUNICATION
+//BY Dr.SANJAY SHARMA
+//CHAPTER 11
+//Information Theory
+clear all;
+clc;
+printf("EXAMPLE 11.13(PAGENO 495)");
+//given
+t_dot = .2//duration of dot symbol
+t_dash = .6//duration of dash symbol
+t_space = .2//time between the symbols
+//wkt sum of the probability is 1 i.e P_dot + P_dash = 1 hence
+//P_dot = 2*P_dash weget
+P_dot = 2/3//probality of dot symbol
+P_dash = 1/3//probality of dash symbol
+
+//calculations
+H_X = -P_dot*log2(P_dot)-P_dash*log2(P_dash);//entropy
+T_s = P_dot*t_dot + P_dash*t_dash +t_space;//average time per symbol
+r = 1/T_s;//average symbol rate
+R = r*H_X;//average information rate of the telegraph sourece
+
+//result
+printf("\n\ni.The average information rate of the telegraph source = %.4f bits/seconds",R);
diff --git a/1895/CH11/EX11.14/EXAMPLE11_14.SCE b/1895/CH11/EX11.14/EXAMPLE11_14.SCE new file mode 100755 index 000000000..780dd1732 --- /dev/null +++ b/1895/CH11/EX11.14/EXAMPLE11_14.SCE @@ -0,0 +1,23 @@ +//ANALOG AND DIGITAL COMMUNICATION
+//BY Dr.SANJAY SHARMA
+//CHAPTER 11
+//Information Theory
+clear all;
+clc;
+printf("EXAMPLE 11.14(PAGENO 496)");
+//given
+//given symbols are equally likely all the symbols the probabilities are same
+Px_1 = 1/8;//probability of first symbol
+Px_2 = 1/8;//probability of second symbol
+Px_3 = 3/8;//probability of third symbol
+Px_4 = 3/8;//probability of fourth symbol
+f_m = poly(0,"f_m");
+r = 2//average symbol rate from problem 11.14
+
+//calculaitons
+H_X = Px_1*log2(1/Px_1) + Px_2*log2(1/Px_2) + Px_3*log2(1/Px_3) + Px_4*log2(1/Px_4);//entropy
+R = H_X*r;//information rate
+
+//results
+printf("\n\ni.Entropy = %.2f bits/symbol",H_X)
+printf("\n\nii.The information rate of all symbols = %.2f*f_m bits/seconds", R);
diff --git a/1895/CH11/EX11.15/EXAMPLE11_15.SCE b/1895/CH11/EX11.15/EXAMPLE11_15.SCE new file mode 100755 index 000000000..aeabadbe2 --- /dev/null +++ b/1895/CH11/EX11.15/EXAMPLE11_15.SCE @@ -0,0 +1,22 @@ +//ANALOG AND DIGITAL COMMUNICATION
+//BY Dr.SANJAY SHARMA
+//CHAPTER 11
+//Information Theory
+clear all;
+clc;
+printf("EXAMPLE 11.15(PAGENO 497)");
+//given
+//given symbols are equally likely all the symbols the probabilities are same
+Px_1 = 1/4;//probability of first symbol
+Px_2 = 1/4;//probability of second symbol
+Px_3 = 1/4;//probability of third symbol
+Px_4 = 1/4;//probability of fourth symbol
+f_m = poly(0,"f_m");
+r = 2//average symbol rate from problem 11.14
+
+//calculaitons
+H_X = Px_1*log2(1/Px_1) + Px_2*log2(1/Px_2) + Px_3*log2(1/Px_3) + Px_4*log2(1/Px_4);//entropy
+R = H_X*r;//information rate
+
+//results
+printf("\n\ni.The information rate of all symbols = %.2f*f_m bits/seconds", R);
diff --git a/1895/CH11/EX11.16/EXAMPLE11_16.SCE b/1895/CH11/EX11.16/EXAMPLE11_16.SCE new file mode 100755 index 000000000..c7b1b273b --- /dev/null +++ b/1895/CH11/EX11.16/EXAMPLE11_16.SCE @@ -0,0 +1,24 @@ +//ANALOG AND DIGITAL COMMUNICATION
+//BY Dr.SANJAY SHARMA
+//CHAPTER 11
+//Information Theory
+clear all;
+clc;
+printf("EXAMPLE 11.16(PAGENO 498)");
+//given
+Px_1 = 1/2;//probability of first symbol
+Px_2 = 1/4;//probability of second symbol
+Px_3 = 1/8;//probability of third symbol
+Px_4 = 1/16;//probability of fourth symbol
+Px_4 = 1/16;//probability of fifth symbol
+T_b = 1*10^-3//time required for emittion of each symbol
+r = 1/(T_b)//symbol rate
+
+//calculations
+H_X = Px_1*log2(1/Px_1) + Px_2*log2(1/Px_2) + Px_3*log2(1/Px_3) + Px_4*log2(1/Px_4) + Px_4*log2(1/Px_4);
+R = r*H_X;//information rate
+
+//results
+printf("\n\ni.Entropy of five symbols = %.2f bits/symbol",H_X);
+
+printf("\n\nii.Rate of information = %.2f bits/sec",R);
diff --git a/1895/CH11/EX11.17/EXAMPLE11_17.SCE b/1895/CH11/EX11.17/EXAMPLE11_17.SCE new file mode 100755 index 000000000..64d2074f0 --- /dev/null +++ b/1895/CH11/EX11.17/EXAMPLE11_17.SCE @@ -0,0 +1,21 @@ +//ANALOG AND DIGITAL COMMUNICATION
+//BY Dr.SANJAY SHARMA
+//CHAPTER 11
+//Information Theory
+clear all;
+clc;
+printf("EXAMPLE 11.17(PAGENO 498)");
+//given
+Px_1 = 1/2;//probability of first symbol
+Px_2 = 1/4;//probability of second symbol
+Px_3 = 1/8;//probability of third symbol
+Px_4 = 1/16;//probability of fourth symbol
+Px_5 = 1/16;//probability of fifth symbol
+r = 16//outcomes per second
+
+//calculations
+H_X = Px_1*log2(1/Px_1) + Px_2*log2(1/Px_2) + Px_3*log2(1/Px_3) + Px_4*log2(1/Px_4) + Px_5*log2(1/Px_5);
+R = r*H_X;//information rate
+
+//result
+printf("\n\nRate of information = %.2f bits/sec",R);
diff --git a/1895/CH11/EX11.18/EXAMPLE11_18.SCE b/1895/CH11/EX11.18/EXAMPLE11_18.SCE new file mode 100755 index 000000000..87f3a47b3 --- /dev/null +++ b/1895/CH11/EX11.18/EXAMPLE11_18.SCE @@ -0,0 +1,27 @@ +//ANALOG AND DIGITAL COMMUNICATION
+//BY Dr.SANJAY SHARMA
+//CHAPTER 11
+//Information Theory
+clear all;
+clc;
+printf("EXAMPLE 11.18(PAGENO 499)");
+//given
+Px_1 = 1/4;//probability of first symbol
+Px_2 = 1/5;//probability of second symbol
+Px_3 = 1/5;//probability of third symbol
+Px_4 = 1/10;//probability of fourth symbol
+Px_5 = 1/10;//probability of fifth symbol
+Px_6 = 1/20;//probability of sixth symbol
+Px_7 = 1/20;//probability of seventh symbol
+Px_8 = 1/20;//probability of eigith symbol
+f_m = 10*10^3//freuency of tranamitting symbol
+
+//calculations
+H_X = Px_1*log2(1/Px_1) + Px_2*log2(1/Px_2) + Px_3*log2(1/Px_3) + Px_4*log2(1/Px_4) + Px_5*log2(1/Px_5) + Px_6*log2(1/Px_6)+ Px_7*log2(1/Px_7)+ Px_8*log2(1/Px_8);//entropy
+f_s = 2*f_m//sampling frequency
+r = f_s//sampling frequency equal to rate of transmission
+R = r*H_X;//information rate
+
+//result
+printf("\n\nRate of information = %.2f bits/sec",R);
+printf("\n\nNote:Their mistake in calculation of H_X in textbook")
diff --git a/1895/CH11/EX11.19/EXAMPLE11_19.SCE b/1895/CH11/EX11.19/EXAMPLE11_19.SCE new file mode 100755 index 000000000..1b0d7d0ff --- /dev/null +++ b/1895/CH11/EX11.19/EXAMPLE11_19.SCE @@ -0,0 +1,23 @@ +//ANALOG AND DIGITAL COMMUNICATION
+//BY Dr.SANJAY SHARMA
+//CHAPTER 11
+//Information Theory
+clear all;
+clc;
+printf("EXAMPLE 11.19(PAGENO 502)");
+//given
+//from fig
+P_X = [.5 .5]//x matrix
+P_Xd = [.5 0; 0 .5]//diagonal x matrix
+//calculations
+P_YX = [.9 .1; .2 .8];//yx matrix representation of given fig
+P_Y = P_X*P_YX//y matrix
+P_XY = P_Xd * P_YX//xy matrix
+
+//results
+printf("\n\ni.Channel matrix of the channelP_YX ");
+disp(P_YX);
+printf("\n\nii.a.P(y1) = %.2f",P_Y(1,1));
+printf("\n\n b.P(y2) = %.2f",P_Y(1,2));
+printf("\n\niii.a.P(x1,y2) = %.2f",P_XY(1,2));
+printf("\n\n b.P(x2,y1) = %.2f",P_XY(2,1));
diff --git a/1895/CH11/EX11.2/EXAMPLE11_2.SCE b/1895/CH11/EX11.2/EXAMPLE11_2.SCE new file mode 100755 index 000000000..5947283ab --- /dev/null +++ b/1895/CH11/EX11.2/EXAMPLE11_2.SCE @@ -0,0 +1,15 @@ +//ANALOG AND DIGITAL COMMUNICATION
+//BY Dr.SANJAY SHARMA
+//CHAPTER 11
+//Information Theory
+clear all;
+clc;
+printf("EXAMPLE 11.2(PAGENO 488)");
+//given
+Px_i = 1/4//probability of a symbol
+
+//calculation
+Ix_i = (log(1/Px_i))/log(2)//formula for amount of information of a symbol
+
+//result
+printf("\n\ni. Amount of information = %.2f bits",Ix_i)
diff --git a/1895/CH11/EX11.20/EXAMPLE11_20.sce b/1895/CH11/EX11.20/EXAMPLE11_20.sce new file mode 100755 index 000000000..625e25bb8 --- /dev/null +++ b/1895/CH11/EX11.20/EXAMPLE11_20.sce @@ -0,0 +1,26 @@ +//ANALOG AND DIGITAL COMMUNICATION
+//BY Dr.SANJAY SHARMA
+//CHAPTER 11
+//Information Theory
+clear all;
+clc;
+printf("EXAMPLE 11.20(PAGENO 503)");
+//given
+P_X = [.5 .5]//x matrix
+
+//calculations
+P_YX = [.9 .1; .2 .8];//yx matrix representation of given fig
+P_ZY = [.9 .1; .2 .8]//zy matrix representation of given fig
+P_Y = P_X *P_YX//y matrix
+P_ZX = P_YX * P_ZY//zx matrix
+P_Z = P_X *P_ZX//z matrix
+
+
+//results
+printf("\n\ni.Channel matrix of the channelP_ZX ");
+disp(P_ZX);
+printf("Matrix P(Z)")
+disp(P_Z);
+printf("\n\na.P(Z1) = %.2f",P_Z(1,1));
+printf("\n\nb.P(Z2) = %.2f",P_Z(1,2));
+
diff --git a/1895/CH11/EX11.21/EXAMPLE11_21.SCE b/1895/CH11/EX11.21/EXAMPLE11_21.SCE new file mode 100755 index 000000000..9543f5a0a --- /dev/null +++ b/1895/CH11/EX11.21/EXAMPLE11_21.SCE @@ -0,0 +1,20 @@ +//ANALOG AND DIGITAL COMMUNICATION
+//BY Dr.SANJAY SHARMA
+//CHAPTER 11
+//Information Theory
+clear all;
+clc;
+printf("EXAMPLE 11.21(PAGENO 504)");
+//given
+P_X = [.5 .5]//x matrix
+P_YX = [.8 .2 0 ; 0 .2 .8];//yx matrix representation of given fig
+
+//calculations
+P_Y = P_X*P_YX;
+
+//results
+printf("\n\norobability associated with the channel outputs for p=.2 is")
+disp(P_Y)
+printf("\n\na.P(Y1) = %.2f",P_Y(1,1));
+printf("\n\nb.P(Y2) = %.2f",P_Y(1,2));
+printf("\n\nC.P(Y3) = %.2f",P_Y(1,3));
diff --git a/1895/CH11/EX11.28/EXAMPLE11_28.SCE b/1895/CH11/EX11.28/EXAMPLE11_28.SCE new file mode 100755 index 000000000..852f62002 --- /dev/null +++ b/1895/CH11/EX11.28/EXAMPLE11_28.SCE @@ -0,0 +1,32 @@ +//ANALOG AND DIGITAL COMMUNICATION
+//BY Dr.SANJAY SHARMA
+//CHAPTER 11
+//Information Theory
+clear all;
+clc;
+printf("EXAMPLE 11.21(PAGENO 504)");
+
+//given
+//wkt P_Y = P_X*P_YX from previous problems
+alfa = .5
+P_1 = .1//probability for first case
+P_2 = .5//probability for second case
+
+//calculations
+P_X = [alfa alfa];
+//first case
+P_YX = [1-P_1 P_1;P_1 1-P_1];
+P_Y1 = P_X*P_YX;
+H_Y1 = -P_Y1(1,1)*log2(P_Y1(1,1))-P_Y1(1,2)*log2(P_Y1(1,2));
+Q_1 = P_1*log2(P_1) + (1-P_1)*log2(1-P_1)//from proof
+ I_XY1 = 1 + Q_1;
+//second case
+P_YX = [1-P_2 P_2;P_2 1-P_2];
+P_Y2 = P_X*P_YX;
+H_Y2 = -P_Y2(1,1)*log2(P_Y2(1,1))-P_Y2(1,2)*log2(P_Y2(1,2));
+Q_2 = P_2*log2(P_2) + (1-P_2)*log2(1-P_2)//from proof
+I_XY2 = 1 + Q_2;
+
+//results
+printf("\n\nI_XY for the first case = %.2f",I_XY1);
+printf("\n\nI_XY for the second case = %.2f",I_XY2);
diff --git a/1895/CH11/EX11.3/EXAMPLE11_3.SCE b/1895/CH11/EX11.3/EXAMPLE11_3.SCE new file mode 100755 index 000000000..fa692e3e7 --- /dev/null +++ b/1895/CH11/EX11.3/EXAMPLE11_3.SCE @@ -0,0 +1,21 @@ +//ANALOG AND DIGITAL COMMUNICATION
+//BY Dr.SANJAY SHARMA
+//CHAPTER 11
+//Information Theory
+clear all;
+clc;
+printf("EXAMPLE 11.3(PAGENO 489)");
+//given
+//since there are only two binary levels i.e. 1 or 0. Since, these two binary levels occur with equal likelihood of occurrence will be
+Px_1 = 1/2//probability of zero level
+Px_2 = 1/2//probability of first level
+
+//calculations
+Ix_1 = log2(1/Px_1)//amount of information of zero level with base 2
+Ix_2 = log2(1/Px_2)//amount of information of first level with base 2
+Ix_1= log(1/Px_1)/log(2)//amount of information content with base 10
+Ix_2 = Ix_1
+
+//result
+printf("\n\ni.Amount of information content wrt binary PCM 0 = %.2f bit",Ix_1)
+printf("\n\nii.Amount of information content wrt binary PCM 1 = %.2f bit",Ix_2)
diff --git a/1895/CH11/EX11.32/EXAMPLE11_32.SCE b/1895/CH11/EX11.32/EXAMPLE11_32.SCE new file mode 100755 index 000000000..ca4d84394 --- /dev/null +++ b/1895/CH11/EX11.32/EXAMPLE11_32.SCE @@ -0,0 +1,21 @@ +//ANALOG AND DIGITAL COMMUNICATION
+//BY Dr.SANJAY SHARMA
+//CHAPTER 11
+//Information Theory
+clear all;
+clc;
+printf("EXAMPLE 11.32(PAGENO 518)");
+//given
+a1 = 1
+a2 = 2
+a3 = .5
+
+//calculations
+H_X1 = log2(a1);//Entropy for first case
+H_X2 = log2(a2);//Entropy for second case
+H_X3 = log2(a3);//Entropy for third case
+
+//results
+printf("\n\ni.Entropy for first case = %.2f ",H_X1);
+printf("\n\nii.Entropy for second case = %.2f",H_X2);
+printf("\n\niii.Entropy for third case = %.2f ",H_X3);
diff --git a/1895/CH11/EX11.35/EXAMPLE11_35.SCE b/1895/CH11/EX11.35/EXAMPLE11_35.SCE new file mode 100755 index 000000000..f8d6be39b --- /dev/null +++ b/1895/CH11/EX11.35/EXAMPLE11_35.SCE @@ -0,0 +1,18 @@ +//ANALOG AND DIGITAL COMMUNICATION
+//BY Dr.SANJAY SHARMA
+//CHAPTER 11
+//Information Theory
+clear all;
+clc;
+printf("EXAMPLE 11.35(PAGENO 520)");
+//given
+B = 4000//bandwidth of AWGN channel
+S = .1*10^-3//power of signal
+neta = 2*10^-12//spectral dencity
+N = neta*B;//power
+
+//calculations
+C = B * log2(1 + (S/N));//capacity of channel
+
+//result
+printf("\n\nCapacity of channel = %.2f b/s",C);
diff --git a/1895/CH11/EX11.37/EXAMPLE11_37.SCE b/1895/CH11/EX11.37/EXAMPLE11_37.SCE new file mode 100755 index 000000000..4d0b4c81e --- /dev/null +++ b/1895/CH11/EX11.37/EXAMPLE11_37.SCE @@ -0,0 +1,25 @@ +//ANALOG AND DIGITAL COMMUNICATION
+//BY Dr.SANJAY SHARMA
+//CHAPTER 11
+//Information Theory
+clear all;
+clc;
+printf("EXAMPLE 11.37(PAGENO 524)");
+//given
+Px_1 = 0.9//probability of first symbol
+Px_2 = 0.1//probability of second symbol
+n1 = 1//length of the code for x_1
+n2 =1//length of code for x_2
+
+//calculations
+//we know that the average code length L per symbol
+L = Px_1*n1 + Px_2*n2//code length
+H_X = -Px_1*log2(Px_1) - Px_2*log2(Px_2) //entropy
+neta = H_X/L//efficiency
+neta1 = neta*100//neta in percentage
+gama = 1 - neta//redundancy
+gama1 = gama*100//gama in percentage
+
+//results
+printf("\n\ni.Efficiency of code = %.2f percent",neta1);
+printf("\n\nii.Code redundancy = %.2f percent ",gama1)
diff --git a/1895/CH11/EX11.38/EXAMPLE11_38.SCE b/1895/CH11/EX11.38/EXAMPLE11_38.SCE new file mode 100755 index 000000000..d8b12d22a --- /dev/null +++ b/1895/CH11/EX11.38/EXAMPLE11_38.SCE @@ -0,0 +1,30 @@ +//ANALOG AND DIGITAL COMMUNICATION
+//BY Dr.SANJAY SHARMA
+//CHAPTER 11
+//Information Theory
+clear all;
+clc;
+printf("EXAMPLE 11.38(PAGENO 524)");
+
+//given
+Px_1 = 0.81//probability of first symbol
+Px_2 = .09//probability of second symbol
+Px_3 = .09//probability of third symbol
+Px_4 = 0.01//probability of forth symbol
+n1 = 1//length of code for a_1
+n2 =2//length of code for a_2
+n3 = 3//length of code for a_3
+n4 = 3//length of code for a_4
+
+//calculations
+//we know that the average code length L per symbol
+L = Px_1*n1 + Px_2*n2 + Px_3*n3 + Px_4*n4 //code length
+H_X = -Px_1*log2(Px_1) - Px_2*log2(Px_2) - Px_3*log2(Px_3) - Px_4*log2(Px_4)//entropy
+neta = H_X/L//efficiency
+neta1 = neta*100//neta in percentage
+gama = 1 - neta//redundancy
+gama1 = gama*100//gama in percentage
+
+//results
+printf("\n\ni.Efficiency of code = %.2f percent",neta1);
+printf("\n\nii.Code redundancy = %.2f percent ",gama1)
diff --git a/1895/CH11/EX11.4/EXAMPLE11_4.sce b/1895/CH11/EX11.4/EXAMPLE11_4.sce new file mode 100755 index 000000000..3c1b451ae --- /dev/null +++ b/1895/CH11/EX11.4/EXAMPLE11_4.sce @@ -0,0 +1,20 @@ +//ANALOG AND DIGITAL COMMUNICATION
+//BY Dr.SANJAY SHARMA
+//CHAPTER 11
+//Information Theory
+clear all;
+clc;
+printf("EXAMPLE 11.4(PAGENO 489)");
+//given
+Px_1 = 1/4//probability wrt to binary PCM '0'
+Px_2 = 3/4//probability wrt to binary PCM '1'
+
+//calculations
+Ix_1 = log2(1/Px_1)//amount of information of zero level with base 2
+Ix_2 = log2(1/Px_2)//amount of information of first level with base 2
+Ix_1= log(1/Px_1)/log(2)//amount of information content with base 10
+Ix_2= log(1/Px_2)/log(2)//amount of information content with base 10
+
+//results
+printf("\n\ni.Amount of information carried wrt to binary PCM 0 = %.2f bits",Ix_1);
+printf("\n\nii.Amount of information carried wrt to binary PCM 1 = %.2f bits",Ix_2);
diff --git a/1895/CH11/EX11.44/EXAMPLE11_44.SCE b/1895/CH11/EX11.44/EXAMPLE11_44.SCE new file mode 100755 index 000000000..bff6bc15e --- /dev/null +++ b/1895/CH11/EX11.44/EXAMPLE11_44.SCE @@ -0,0 +1,31 @@ +//ANALOG AND DIGITAL COMMUNICATION
+//BY Dr.SANJAY SHARMA
+//CHAPTER 11
+//Information Theory
+clear all;
+clc;
+printf("EXAMPLE 11.44(PAGENO 529)");
+
+//given
+P_x1 = 1/2//probability of first symbol
+P_x2 = 1/4//probability of second symbol
+P_x3 = 1/8//probability of third symbol
+P_x4 = 1/8//probability of fouth symbol
+n1 = 1
+n2 = 2
+n3 = 3
+n4 = 3
+
+//calculations
+I_x1 = -log2(P_x1);
+I_x2 = -log2(P_x2);
+I_x3 = -log2(P_x3);
+I_x4 = -log2(P_x4);
+H_x = P_x1*I_x1 + P_x2*I_x2 + P_x3*I_x3 + P_x4*I_x4;
+L = P_x1*n1 + P_x2*n2 + P_x3*n3 + P_x4*n4;
+neta = H_x/L;
+P_neta = neta*100//efficiency in percentage
+
+//results
+printf("\n\nEfficiency = %.2f",neta);
+printf("\n\nEfficiency in percentage = %.2f percent",P_neta);
diff --git a/1895/CH11/EX11.46/EXAMPLE11_46.sce b/1895/CH11/EX11.46/EXAMPLE11_46.sce new file mode 100755 index 000000000..2d9394e8f --- /dev/null +++ b/1895/CH11/EX11.46/EXAMPLE11_46.sce @@ -0,0 +1,38 @@ +//ANALOG AND DIGITAL COMMUNICATION
+//BY Dr.SANJAY SHARMA
+//CHAPTER 11
+//Information Theory
+clear all;
+clc;
+printf("EXAMPLE 11.46(PAGENO 532)");
+
+//given
+P_x1 = .4//probability of first signal
+P_x2 = .19//probability of second signal
+P_x3 = .16//probability of third signal
+P_x4 = .15//probability of fourth signal
+P_x5 = .1//probability of fifth signal
+n1 = 1//number of bits in code obtained from table givenn textbook
+n2 = 2//number of bits in code obtained from table givenn textbook
+n3 = 2//number of bits in code obtained from table givenn textbook
+n4 = 3//number of bits in code obtained from table givenn textbook
+n5 = 3//number of bits in code obtained from table givenn textbook
+
+//calculations
+I_x1 = -log2(P_x1);
+I_x2 = -log2(P_x2);
+I_x3 = -log2(P_x3);
+I_x4 = -log2(P_x4);
+I_x5 = -log2(P_x5);
+H_x = P_x1*I_x1 + P_x2*I_x2 + P_x3*I_x3 + P_x4*I_x4 + P_x5*I_x5;//entropy
+L1 = P_x1*n1 + P_x2*n2 + P_x3*n3 + P_x4*n4 + P_x5*n5;
+neta1 = H_x/L1;
+P_neta1 = neta1*100//efficiency in percentage using Shannon Fano code
+L2 = P_x1*1 + (P_x2 + P_x3 +P_x4 +P_x5 )*3
+neta2 = H_x/L2;
+P_neta2 = neta2*100//efficiency in percentage using huffman code
+
+//results
+printf("\n\nEfficiency in percentage using Shannon Fano code = %2f percent",P_neta1)
+printf("\n\nEfficiency in percentage using huffman code = %2f percent",P_neta2)
+printf("\n\nNote: There is mistake in the textbook in calculation of L using SHannon Fano code")
diff --git a/1895/CH11/EX11.47/EXAMPLE11_47.SCE b/1895/CH11/EX11.47/EXAMPLE11_47.SCE new file mode 100755 index 000000000..bd756a9d8 --- /dev/null +++ b/1895/CH11/EX11.47/EXAMPLE11_47.SCE @@ -0,0 +1,38 @@ +//ANALOG AND DIGITAL COMMUNICATION
+//BY Dr.SANJAY SHARMA
+//CHAPTER 11
+//Information Theory
+clear all;
+clc;
+printf("EXAMPLE 11.44(PAGENO 532)");
+
+//given
+P_x1 = .05//probability of first signal
+P_x2 = .15//probability of second signal
+P_x3 = .2//probability of third signal
+P_x4 = .05//probability of fourth signal
+P_x5 = .15//probability of fifth signal
+P_x6 = .3//probability of sixth signal
+P_x7 = .1//probability of seventh signal
+n1 = 4//number of bits in code obtained from table given textbook
+n2 = 3//number of bits in code obtained from table given textbook
+n3 = 2//number of bits in code obtained from table given textbook
+n4 = 4//number of bits in code obtained from table given textbook
+n5 = 3//number of bits in code obtained from table given textbook
+n6 = 2//number of bits in code obtained from table given textbook
+n7 = 3//number of bits in code obtained from table given textbook
+
+//calculations
+I_x1 = -log2(P_x1);
+I_x2 = -log2(P_x2);
+I_x3 = -log2(P_x3);
+I_x4 = -log2(P_x4);
+I_x5 = -log2(P_x5);
+I_x6 = -log2(P_x6);
+I_x7 = -log2(P_x7);
+H_x = P_x1*I_x1 + P_x2*I_x2 + P_x3*I_x3 + P_x4*I_x4 + P_x5*I_x5 + P_x6*I_x6 + P_x7*I_x7;//entropy
+L = P_x1*n1 + P_x2*n2 + P_x3*n3 + P_x4*n4 + P_x5*n5 + P_x6*n6 + P_x7*n7;
+neta = (H_x*100)/L//Efficiency in percentage
+
+//results
+printf("\n\nEfficiency in percentage = %.2f percent",neta);
diff --git a/1895/CH11/EX11.49/EXAMPLE11_49.SCE b/1895/CH11/EX11.49/EXAMPLE11_49.SCE new file mode 100755 index 000000000..ab3e90257 --- /dev/null +++ b/1895/CH11/EX11.49/EXAMPLE11_49.SCE @@ -0,0 +1,27 @@ +//ANALOG AND DIGITAL COMMUNICATION
+//BY Dr.SANJAY SHARMA
+//CHAPTER 11
+//Information Theory
+clear all;
+clc;
+printf("EXAMPLE 11.49(PAGENO 534)");
+
+//given
+P_x1 = .4//probability of first signal
+P_x2 = .2//probability of second signal
+P_x3 = .8//probability of third signal
+P_x4 = .08//probability of fourth signal
+P_x5 = .02//probability of fifth signal
+n1 = 2//number of bits in code obtained from table given textbook
+n2 = 3//number of bits in code obtained from table given textbook
+n3 = 1//number of bits in code obtained from table given textbook
+n4 = 4//number of bits in code obtained from table given textbook
+n5 = 4//number of bits in code obtained from table given textbook
+
+//calculations
+L = P_x1*n1 + P_x2*n2 + P_x3*n3 + P_x4*n4 + P_x5*n5;//average codeword length per symbol
+//since sigma = sqrt(summation of product of probability and (n- L)^2)
+sigmasquare = P_x1*(n1-L)^2 + P_x2*(n2-L)^2 +P_x3*(n3-L)^2 + P_x4*(n4-L)^2 +P_x5*(n5-L)^2;//Variance of codewoed length
+
+//results
+printf("\n\nVariance of codeword length =%.4f",sigmasquare)
diff --git a/1895/CH11/EX11.50/EXAMPLE11_50.SCE b/1895/CH11/EX11.50/EXAMPLE11_50.SCE new file mode 100755 index 000000000..1b5d6c205 --- /dev/null +++ b/1895/CH11/EX11.50/EXAMPLE11_50.SCE @@ -0,0 +1,30 @@ +//ANALOG AND DIGITAL COMMUNICATION
+//BY Dr.SANJAY SHARMA
+//CHAPTER 11
+//Information Theory
+clear all;
+clc;
+printf("EXAMPLE 11.50(PAGENO 535)");
+
+//given
+P_x1 = 1/2//probability of first signal
+P_x2 = 1/4//probability of second signal
+P_x3 = 1/8//probability of third signal
+P_x4 = 1/16//probability of fourth signal
+P_x5 = 1/32//probability of fifth signal
+P_x6 = 1/32//probability of sixth signal
+r = 16//message rate in outcomes per second
+
+//calculations
+I_x1 = -log2(P_x1);
+I_x2 = -log2(P_x2);
+I_x3 = -log2(P_x3);
+I_x4 = -log2(P_x4);
+I_x5 = -log2(P_x5);
+I_x6 = -log2(P_x6);
+H_X = P_x1*I_x1 + P_x2*I_x2 + P_x3*I_x3 + P_x4*I_x4 + P_x5*I_x5 + P_x6*I_x6 //entropy
+R = H_X*r//Information rate
+
+//results
+printf("\n\nEntropy of the system =%.2f bits/message",H_X);
+printf("\n\nInformation rate = %.2f bits/seconds",R);
diff --git a/1895/CH11/EX11.51/EXAMPLE11_51.SCE b/1895/CH11/EX11.51/EXAMPLE11_51.SCE new file mode 100755 index 000000000..dc61fab4b --- /dev/null +++ b/1895/CH11/EX11.51/EXAMPLE11_51.SCE @@ -0,0 +1,31 @@ +//ANALOG AND DIGITAL COMMUNICATION
+//BY Dr.SANJAY SHARMA
+//CHAPTER 11
+//Information Theory
+clear all;
+clc;
+printf("EXAMPLE 11.51(PAGENO 535)");
+
+//given
+P_x1 = .3//probability of first signal
+P_x2 = .4//probability of second signal
+P_x3 = .3//probability of third signal
+P_YX = [.8 .2 0;0 .1 0; 0 .3 0.7]//matrix obtained from the figure
+
+//calculations
+I_x1 = -log2(P_x1);
+I_x2 = -log2(P_x2);
+I_x3 = -log2(P_x3);
+H_X = P_x1*I_x1 + P_x2*I_x2 + P_x3*I_x3 //entropy
+P_y1 = P_YX(1,1)*P_x1 + P_YX(1,2)*P_x1 + P_YX(1,3)*P_x1;
+P_y2 = P_YX(2,1)*P_x2 + P_YX(2,2)*P_x2 + P_YX(2,3)*P_x2;
+P_y3 = P_YX(3,1)*P_x3 + P_YX(3,2)*P_x3 + P_YX(3,3)*P_x3;
+I_y1 = -log2(P_y1);
+I_y2 = -log2(P_y2);
+I_y3 = -log2(P_y3);
+H_Y = -P_y1*I_y1 - P_y2*I_y2 - P_y3*I_y3 //entropy
+
+//results
+printf("\n\n Entropy H(X) = %.2f",H_X );
+printf("\n\nEntropy H(Y) = %.2f",H_Y);
+printf("\n\n Note:There is mistake in the calculation of P_y3 in the textbook so their is change in entropy H_Y")
diff --git a/1895/CH11/EX11.52/EXAMPLE11_52.SCE b/1895/CH11/EX11.52/EXAMPLE11_52.SCE new file mode 100755 index 000000000..e96e2d242 --- /dev/null +++ b/1895/CH11/EX11.52/EXAMPLE11_52.SCE @@ -0,0 +1,23 @@ +//ANALOG AND DIGITAL COMMUNICATION
+//BY Dr.SANJAY SHARMA
+//CHAPTER 11
+//Information Theory
+clear all;
+clc;
+printf("EXAMPLE 11.52(PAGENO 536)");
+
+//given
+P_x1 = .7//probability of first signal
+P_x2 = .15//probability of second signal
+P_x3 = .15//probability of third signal
+n = 2//second order extention
+
+//calculations
+I_x1 = -log2(P_x1);
+I_x2 = -log2(P_x2);
+I_x3 = -log2(P_x3);
+H_x = P_x1*I_x1 + P_x2*I_x2 + P_x3*I_x3//entropy
+H_x2 = n*H_x//entropy of second order extention
+
+//results
+printf("\n\nEntropy of second order extention = %.3f bits/symbol",H_x2);
diff --git a/1895/CH11/EX11.54/EXAMPLE11_54.SCE b/1895/CH11/EX11.54/EXAMPLE11_54.SCE new file mode 100755 index 000000000..9dfaf057b --- /dev/null +++ b/1895/CH11/EX11.54/EXAMPLE11_54.SCE @@ -0,0 +1,23 @@ +//ANALOG AND DIGITAL COMMUNICATION
+//BY Dr.SANJAY SHARMA
+//CHAPTER 11
+//Information Theory
+clear all;
+clc;
+printf("EXAMPLE 11.54(PAGENO 537)");
+
+//given
+P_x1 = 1/3//probability of first signal
+P_x2 = 1/6//probability of second signal
+P_x3 = 1/4//probability of third signal
+P_x4 = 1/4//probability of fourth signal
+
+//calculations
+I_x1 = -log2(P_x1);
+I_x2 = -log2(P_x2);
+I_x3 = -log2(P_x3);
+I_x4 = -log2(P_x4);
+H_x = P_x1*I_x1 + P_x2*I_x2 + P_x3*I_x3 + P_x4*I_x4 //entropy
+
+//results
+printf("\n\nEntropy of the source = %.5f bits/symbol ",H_x)
diff --git a/1895/CH11/EX11.55/EXAMPLE11_55.SCE b/1895/CH11/EX11.55/EXAMPLE11_55.SCE new file mode 100755 index 000000000..ea4cfd0bc --- /dev/null +++ b/1895/CH11/EX11.55/EXAMPLE11_55.SCE @@ -0,0 +1,25 @@ +//ANALOG AND DIGITAL COMMUNICATION
+//BY Dr.SANJAY SHARMA
+//CHAPTER 11
+//Information Theory
+clear all;
+clc;
+printf("EXAMPLE 11.55(PAGENO 538)");
+
+//given
+P_x1 = 1/2//probability of first signal
+P_x2 = 1/4//probability of second signal
+P_x3 = 1/8//probability of third signal
+P_x4 = 1/16//probability of fourth signal
+P_x5 = 1/16//probability of fifth signal
+n1 = 1//number of bits in code obtained from table given textbook
+n2 = 2//number of bits in code obtained from table given textbook
+n3 = 3//number of bits in code obtained from table given textbook
+n4 = 4//number of bits in code obtained from table given textbook
+n5 = 4//number of bits in code obtained from table given textbook
+
+//calculations
+L = P_x1*n1 + P_x2*n2 + P_x3*n3 + P_x4*n4 + P_x5*n5;//Average number of bits per message
+
+//results
+printf("\n\nAverage number of bits per message = %.2f bits",L);
diff --git a/1895/CH11/EX11.56/EXAMPLE11_56.SCE b/1895/CH11/EX11.56/EXAMPLE11_56.SCE new file mode 100755 index 000000000..c32687b09 --- /dev/null +++ b/1895/CH11/EX11.56/EXAMPLE11_56.SCE @@ -0,0 +1,19 @@ +//ANALOG AND DIGITAL COMMUNICATION
+//BY Dr.SANJAY SHARMA
+//CHAPTER 11
+//Information Theory
+clear all;
+clc;
+printf("EXAMPLE 11.56(PAGENO 538)");
+
+//given
+B = 3.4*10^3//bandwidth
+SbyN = 30//signal to the noise ratio in dB
+
+
+//calculations
+SbyN1 = exp((SbyN/10)*log(10))//signal to noise ratio
+C = B*log2(1+SbyN1);
+
+//result
+printf("\n\nInformation capacity of the telephone channel = %.2f kbps",C);
diff --git a/1895/CH11/EX11.9/EXAMPLE11_9.SCE b/1895/CH11/EX11.9/EXAMPLE11_9.SCE new file mode 100755 index 000000000..5eaf36344 --- /dev/null +++ b/1895/CH11/EX11.9/EXAMPLE11_9.SCE @@ -0,0 +1,26 @@ +//ANALOG AND DIGITAL COMMUNICATION
+//BY Dr.SANJAY SHARMA
+//CHAPTER 11
+//Information Theory
+clear all;
+clc;
+printf("EXAMPLE 11.9(PAGENO 492)");
+//given
+Px_1 = .4//probability of first symbol
+Px_2 = .3//probability of second symbol
+Px_3 = .2//probability of third symbol
+Px_4 = .1//probability of fourth symbol
+
+//calculations
+H_X = -Px_1*log2(Px_1)-Px_2*log2(Px_2)-Px_3*log2(Px_3)-Px_4*log2(Px_4);//entropy
+Px1x2x1x3 = Px_1*Px_2*Px_1*Px_3;//product of probabilities
+Ix1x2x1x3 =-log2(Px1x2x1x3);//information of four symbols
+Px4x3x3x2 = Px_4*Px_3*Px_3*Px_2;//product of probabilities
+Ix4x3x3x2 = -log2(Px4x3x3x2);//information of four symbols
+
+//results
+printf("\n\ni.Entorpy = %.2f bits/symbol",H_X);
+printf("\n\nii.Amount of information contained in x1x2x1x3 = %.2f bits/symbol",Ix1x2x1x3);
+printf("\nThus,Ix1x2x1x3 < 7.4[=4*H_X]bits/symbol")
+printf("\n\niii.Amount of information contained in x4x3x3x2 =%.2f bits/symbol",Ix4x3x3x2);
+printf("\nThus we conclude that\nIx4x3x3x2 > 7.4[=4*H_X]bits/symbol")
|