diff options
Diffstat (limited to 'Digital_Communications_by_S_Sharma')
8 files changed, 3969 insertions, 0 deletions
diff --git a/Digital_Communications_by_S_Sharma/10-ERROR_CONTROL_CODING.ipynb b/Digital_Communications_by_S_Sharma/10-ERROR_CONTROL_CODING.ipynb new file mode 100644 index 0000000..32b9445 --- /dev/null +++ b/Digital_Communications_by_S_Sharma/10-ERROR_CONTROL_CODING.ipynb @@ -0,0 +1,142 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 10: ERROR CONTROL CODING" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.17: code_vectors.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: code vectors\n", +"//Example 10.17\n", +"//page no 498\n", +"//Determine all possible code vectors \n", +"clc;\n", +"clear;\n", +"m3=1;\n", +"m2=0;\n", +"m1=1;\n", +"m0=0;\n", +"//M=Message Matrix\n", +"//G=Generator Matrix\n", +"G=[1 0 1 1 0 0 0;0 1 0 1 1 0 0;0 0 1 0 1 1 0;0 0 0 1 0 1 1];\n", +"M=[m3 m2 m1 m0;];\n", +"X=M*G;\n", +"for i=1:7;\n", +" if X(i)>1\n", +" X(i)=0\n", +" end\n", +" end\n", +"disp(X,'The code vectors are ');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.19: code_word.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: code word\n", +"//Example 10.19\n", +"//page no 501\n", +"//Determine code word \n", +"clc;\n", +"clear;\n", +"m3=1;\n", +"m2=0;\n", +"m1=1;\n", +"m0=0;\n", +"//M=Message Matrix\n", +"//G=Generator Matrix\n", +"G=[1 0 0 0 1 0 1;0 1 0 0 1 1 1;0 0 1 0 1 1 0;0 0 0 1 0 1 1];\n", +"M=[m3 m2 m1 m0;];\n", +"X=M*G;\n", +"for i=1:7;\n", +" if X(i)>1\n", +" X(i)=0\n", +" end\n", +" end\n", +"disp(X,'The required code word ');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.4: errors_and_corrected_errors.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: errors,corrected errors\n", +"//Example 10.4\n", +"//page no 464\n", +"//Find detected errors,corrected errors\n", +"clear;\n", +"clc;\n", +"dmin=5\n", +" // (s+1)<= dmin number errors can be detected(s)\n", +" s=dmin-1;\n", +"printf(' i)Number of detected errors \n\n \t s <= %d ',s );\n", +"//(2t+1)<=dmin number errors can be corrected(t)\n", +"t=(dmin-1)/2;\n", +"\n", +"printf('\n\n ii) Number of corrected errors\n\n \t t<= %d ',t );" + ] + } +], +"metadata": { + "kernelspec": { + "display_name": "Scilab", + "language": "scilab", + "name": "scilab" + }, + "language_info": { + "file_extension": ".sce", + "help_links": [ + { + "text": "MetaKernel Magics", + "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md" + } + ], + "mimetype": "text/x-octave", + "name": "scilab", + "version": "0.7.1" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/Digital_Communications_by_S_Sharma/2-PROBABILITY_RANDOM_SIGNALS_AND_RANDOM_PROCESS.ipynb b/Digital_Communications_by_S_Sharma/2-PROBABILITY_RANDOM_SIGNALS_AND_RANDOM_PROCESS.ipynb new file mode 100644 index 0000000..63e2df4 --- /dev/null +++ b/Digital_Communications_by_S_Sharma/2-PROBABILITY_RANDOM_SIGNALS_AND_RANDOM_PROCESS.ipynb @@ -0,0 +1,729 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 2: PROBABILITY RANDOM SIGNALS AND RANDOM PROCESS" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.12: Probability_density_function.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Probability density function \n", +"//Example 2.12\n", +"//Find find the value of k\n", +"clc;\n", +"clear;\n", +"function y=FX1(x) //for -infinte<x<=0\n", +" y=0 \n", +"endfunction\n", +"function y=FX2(x) //for 0<x<=10\n", +" y=k*x^2 \n", +"endfunction\n", +"function y=FX3(x) //for 10<x<infine\n", +" y=100*k\n", +"endfunction\n", +"k=poly(0,'k');\n", +" //from the expression for CDF is given\n", +"y=100*k //for 10<x<infine\n", +"y==1; \n", +"k=1/100; //k=y/100\n", +"disp(k,'i) k = ');\n", +"//CDF function can be expressed\n", +"// FX(x)=P(X<=x)\n", +"P5=FX2(5); //x=5\n", +"disp(P5,'ii) P(X<=5) = ');\n", +" //now differentiating with respect tox we ,have \n", +" //PDF fX=0 for -infinte<x<=0,10<x<infine\n", +"x=poly(0,'x');\n", +"m=x^2/100;\n", +"df=derivat(m); // for 0<x<=10\n", +"disp(' for 0<x<=10',df,'iii)PDF a) fX(x) =');\n", +"disp(' -infinte<x<=0,10<x<infine',0,' b)fX(x) = ');\n", +"\n", +"x1=5,x2=7;\n", +"function y=z(x),\n", +" y=x/50;\n", +"endfunction\n", +"P=intg(x1,x2,z);\n", +"disp(P,'iv) P(5<X<=7) =');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.13: Probability.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Probability \n", +"//Example 2.13\n", +"//page no 54\n", +"//find the probability \n", +"clc;\n", +"clear;\n", +"function y=f(x),\n", +" y=2*exp(-(2*x)),//Probability Density Function\n", +"endfunction\n", +"\n", +"a=1;\n", +"b=3;\n", +"P=intg(a,b,f);//probability that random variable between 1 and 3\n", +"disp(P,'P(1<X<3)=');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.14: Probability.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Probability \n", +"//Example 2.14\n", +"//page no 54\n", +"//find the probability \n", +"clc;\n", +"clear;\n", +"function y=f(x),\n", +" y=12*x^3-21*x^2+10*x,//Probability Density Function\n", +"endfunction\n", +"a=0;\n", +"b=1/2;\n", +"P=intg(a,b,f);\n", +"disp(P,'P(X<=1/2)=');\n", +"disp(1-P,'P(X>1/2)=');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.1_a: Probability.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Probability\n", +"//Example 2.1.a\n", +"//page no 43\n", +"//Find the Probability \n", +"clc;\n", +"clear;\n", +"redballs=3;\n", +"whiteballs=4;\n", +"blackballs=5; \n", +"//P=ways of choosing a red ball/Total no. of ways choosing a ball\n", +"Pro=redballs/(redballs+whiteballs+blackballs);\n", +"disp('Probability Getting red ball is');\n", +"disp(Pro,'P(R)=');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.1_b: Probability.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"\n", +"//Caption: Probability\n", +"//Example 2_1b\n", +"//page no 43\n", +"//Find the probability Getting black ball\n", +"clc;\n", +"clear;\n", +"redballs=3;\n", +"whiteballs=4;\n", +"blackballs=5;\n", +"//Probability Getting black ball\n", +"prob=blackballs/(redballs+whiteballs+blackballs);\n", +"p=1-prob;\n", +"disp('Probability not getting black ball');\n", +"disp(p,'P(B~)=');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.1_c: Probability.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Probability\n", +"//Example 2.1.c\n", +"//page no 43\n", +"//Find the probability \n", +"clc;\n", +"clear;\n", +"redballs=3;\n", +"whiteballs=4;\n", +"blackballs=5;\n", +"//Probability Getting black ball\n", +"pb=blackballs/(redballs+whiteballs+blackballs);\n", +"//Probability Getting white ball\n", +"pw=whiteballs/(redballs+whiteballs+blackballs);\n", +"//Probability Getting white ball or black ball\n", +"pwb=pb+pw// black and white are mutuallly exclusive events\n", +"disp('Probability Getting white ball or black ball will be ')\n", +"disp(pwb,'P(B+W)=')\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.20: Joint_probability.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Joint probability\n", +"//Example 2.20\n", +"//Page no 60\n", +"//Find Determine the value of constant C\n", +"clc;\n", +"clear;\n", +"X=[0,0;2,2;2,0];\n", +"Y=[0,0;3,3;0,3];\n", +"function y=f(x,y),\n", +" y=2*x+y;\n", +"endfunction\n", +"P=int2d(X,Y,f);\n", +"C=poly(0,'C');\n", +"//we know that joint PDF \n", +"// double integration fXY(x,y)dxdy=1\n", +"//C*P==1;\n", +"C=1/P;\n", +"disp(C,'C = ')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.23: probability_density_function.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: probability density function \n", +"//Example 2.23\n", +"//page no \n", +"//verify the area under curve is unity,prove that the mean is zero\n", +"clc;\n", +"clear;\n", +"//continuous random variable X in the range(-3,3)\n", +"//PDF of fucntions\n", +"function y=fX1(x)\n", +" y=((3+x)^2)/16; //for -3<=x<=-1\n", +"endfunction\n", +"a1=-3;\n", +"a2=-1;\n", +"\n", +"function y=fX2(x), //for-1<=x<=1\n", +" y=(6-2*x^2)/16;\n", +"endfunction\n", +"b1=-1;\n", +"b2=1;\n", +"\n", +"function y=fX3(x)\n", +" y=((3-x)^2)/16; //for 1<=x<=3\n", +"endfunction\n", +"c1=1;\n", +"c2=3;\n", +"//area under pdf curve\n", +"//area = integral Fx(x)dx from -3 to 3\n", +"area =intg(a1,a2,fX1)+intg(b1,b2,fX2)+intg(c1,c2,fX3);\n", +"disp(area,'Area =');\n", +"disp(' Therefore area under PDF curve is unity.');\n", +"function y=f1(x)\n", +" y=(x*(3+x)^2)/16; //for -3<=x<=-1\n", +"endfunction\n", +"a1=-3;\n", +"a2=-1;\n", +"\n", +"function y=f2(x), //for-1<=x<=1\n", +" y=(x*(6-2*x^2))/16;\n", +"endfunction\n", +"b1=-1;\n", +"b2=1;\n", +"function y=f3(x)\n", +" y=(x*(3-x)^2)/16; //for 1<=x<=3\n", +"endfunction\n", +"c1=1;\n", +"c2=3;\n", +"mx=intg(a1,a2,f1)+intg(b1,b2,f2)+intg(c1,c2,f3);//mean value\n", +"disp(mx,'Mean value =');\n", +"disp(' Therefore mean value is zero.');\n", +"//Therefore area under PDF curve is unity\n", +"//Hence Therefore mean value is zero" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.24: mean_mean_Square_Standard_deviation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: mean ,mean Square Standard deviation\n", +"//Example 2.24\n", +"//page no \n", +"//Find mean,mean Square ,Standard deviation\n", +"clc;\n", +"clear;\n", +"function y=f(x)\n", +" y=x/(2*%pi); //for 0<=x<=2*%pi\n", +"endfunction\n", +"\n", +"a=0;\n", +"b=2*%pi;\n", +"mx=intg(a,b,f);//mean value\n", +"disp(mx,'Mean value mx=');\n", +"\n", +"function y=fX(x)\n", +" y=x^2/(2*%pi); //for 0<=x<=2*%pi\n", +"endfunction\n", +"a=0;\n", +"b=2*%pi;\n", +"//X^2=E(X^2) \n", +"X2=intg(a,b,fX);//mean square value\n", +"disp(X2,'Mean square value X^2 =');\n", +"\n", +"sigma2=X2-mx^2;//variance\n", +"sigma=sqrt(sigma2);//Standard deviation\n", +"disp(sigma,'Standard deviation sigma=')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.2: Probability.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Probability\n", +"//Example 2.2\n", +"//page no 43\n", +"//find the probability of getting 5\n", +"clc;\n", +"clear;\n", +"total_possibleoutcomes=6*6;\n", +"probabilityofeachoutcome=1/total_possibleoutcomes;//probability of each outcome\n", +"noofways=4; //ways of getting 5\n", +"probability=noofways*probabilityofeachoutcome;//probability of getting 5\n", +"disp(probability,'Probability of getting 5 is');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.31: Mean_and_Variance.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Mean,Variance\n", +"//Example 2.31\n", +"//page no 85\n", +"//find i)Mean\n", +"// ii)Variance of given function\n", +"clc;\n", +"clear;\n", +"\n", +"//Mean Value\n", +"function X=f(x),\n", +" z=3*(1-x)^2,//Marginal Probability Density Function\n", +" X=x*z\n", +"endfunction\n", +"a=0;\n", +"b=1;\n", +"EX=intg(a,b,f);//Mean value of X\n", +"\n", +"function Y=c(y)\n", +" z=3*(1-y)^2,//Marginal Probability Density Function\n", +" Y=y*z\n", +"endfunction\n", +"\n", +"EY=intg(a,b,c);//Mean value of Y\n", +"disp(EX,'i)Mean of X =')\n", +"disp(EY,' Mean of Y =')\n", +"\n", +"//Variance\n", +"function X=g(x),\n", +" z=3*(1-x)^2,//Marginal Probability Density Function\n", +" X=x^2*z\n", +"endfunction\n", +"a=0;\n", +"b=1;\n", +"EX2=intg(a,b,g);\n", +"\n", +"function Y=h(y)\n", +" z=3*(1-y)^2,//Marginal Probability Density Function\n", +" Y=y^2*z\n", +"endfunction\n", +"\n", +"EY2=intg(a,b,h);\n", +"\n", +"vX2=EX2-(EX)^2;//Variance of X\n", +"vY2=EY2-(EY)^2;//Variance of Y\n", +"\n", +"disp(vX2,'ii)Variance of X');\n", +"\n", +"disp(vY2,' Variance of Y');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.3: Probability.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Probability\n", +"//Example 2.3\n", +"//page no 43\n", +"//find the probability \n", +"clc;\n", +"clear;\n", +"total_cards=52;\n", +"ways_of_drawingtwocards=52*51/(2*1);//ways of drawing 2cards from a deck of 52cards\n", +"diamonds=13;\n", +"Hearts=13;\n", +"waysof_diamonds_Hearts=diamonds*Hearts;//ways of drawing a Diamond and a Heart\n", +"probability=waysof_diamonds_Hearts/ways_of_drawingtwocards;\n", +"\n", +"disp(probability,'Probability that one card is Diamond and Othercard is Heart');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.4: Probability.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Probability\n", +"//Example 2.4\n", +"//page no 44\n", +"//find the probability \n", +"clc;\n", +"clear;\n", +"whiteballs=4;\n", +"blackballs=3;\n", +"pa1=whiteballs/(whiteballs+blackballs);//probability of first ball is white\n", +"pa2=(whiteballs-1)/(whiteballs+blackballs-1);//probability of second ball is white\n", +"pa3=(blackballs)/(whiteballs+blackballs-2);//probability of third ball is black\n", +"required_probability=pa1*pa2*pa3;\n", +"disp(required_probability,'probability of first two balls are white and third ball is black');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.5: Probability.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"\n", +"//Caption: Probability\n", +"//Example 2.5\n", +"//page no 44\n", +"//find the probability \n", +"clc;\n", +"clear;\n", +"whiteballs=5;\n", +"redballs=3;\n", +"balckballs=2;\n", +"totalballs=whiteballs+redballs+balckballs;\n", +"pw=whiteballs/totalballs;//probability of gettingfirst ball is white\n", +"pr=redballs/(totalballs-1);//probability of getting second ball is red\n", +"pb=balckballs/(totalballs-2);//probability of getting third ball is black\n", +"\n", +"possbilecases=6;\n", +"probabalityof_eachcase=pw*pr*pb;\n", +"totalprobability=6*probabalityof_eachcase;//required probability\n", +"disp(totalprobability,'Probability of balls will be in different colours');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.6: Probability.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Probability\n", +"//Example 2.6\n", +"//page no 45\n", +"//find the probability \n", +"clc;\n", +"clear;\n", +"//Probability of solving the problem\n", +"PA=3/4;\n", +"PB=2/3;\n", +"PC=1/4;\n", +"//Probability of not not able solving the problem\n", +"PNA=1-PA;\n", +"PNB=1-PB;\n", +"PNC=1-PC;\n", +"//probability that no one will solve the problem\n", +"probability_notsolve=PNA*PNB*PNC;\n", +"//probability that problem willbe solved\n", +"probability_solve=1-probability_notsolve;\n", +"disp(probability_solve,'probability that problem willbe solved');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.7: Probability.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Probability\n", +"//Example 2.7\n", +"//page no 45\n", +"//find the probability \n", +"clc;\n", +"clear;\n", +"whiteballs=3;\n", +"redballs=2;\n", +"totalballs=whiteballs+redballs;\n", +"pw1=whiteballs/totalballs;//probability of first ball is white\n", +"pr2=redballs/(totalballs-1)//conditional probability event second ball is red with first white\n", +"probability=pw1*pr2//probability of second ball is red with first ball is white\n", +"disp(probability,'probability of first ball is white and second ball is red');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.8: Probability.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Probability\n", +"//Example 2.8\n", +"//page no 45\n", +"//find the probability that recorded number is 2\n", +"clc;\n", +"clear;\n", +"head=1/2;//probability of getting head\n", +"tail=1-head;//probability of getting tail\n", +"head2= head*1/6;//probability of getting head with recorded number is 2\n", +"tail2=tail*1/36;//probability of getting tail with recorded number is 2\n", +"\n", +"//probability of getting recorded number is 2\n", +"p=head2+tail2;\n", +"disp(p,'probability of getting recorded number is 2');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.9: Probability.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Probability\n", +"//Example 2.9\n", +"//page no 46\n", +"//find the probability \n", +"clc;\n", +"clear;\n", +"PA=1/8;\n", +"PB=1/12;\n", +"probability_makingerror=1/10001;\n", +"probability=(PA*PB)/((PA*PB)+((1-PA)*(1-PB)*probability_makingerror));\n", +"disp(probability,'Probability of program is correct');" + ] + } +], +"metadata": { + "kernelspec": { + "display_name": "Scilab", + "language": "scilab", + "name": "scilab" + }, + "language_info": { + "file_extension": ".sce", + "help_links": [ + { + "text": "MetaKernel Magics", + "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md" + } + ], + "mimetype": "text/x-octave", + "name": "scilab", + "version": "0.7.1" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/Digital_Communications_by_S_Sharma/3-SAMPLING_THEORY_AND_PULSE_MODULATION.ipynb b/Digital_Communications_by_S_Sharma/3-SAMPLING_THEORY_AND_PULSE_MODULATION.ipynb new file mode 100644 index 0000000..01b8862 --- /dev/null +++ b/Digital_Communications_by_S_Sharma/3-SAMPLING_THEORY_AND_PULSE_MODULATION.ipynb @@ -0,0 +1,242 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 3: SAMPLING THEORY AND PULSE MODULATION" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.1: Nquist_Rate.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Nquist Rate\n", +"//Example 3.1 \n", +"//page no 102\n", +"//find Nquist Rate\n", +"//given \n", +"clc;\n", +"clear;\n", +"w1=50*%pi;\n", +"w2=300*%pi;\n", +"w3=100*%pi;\n", +"//w=2*%pi*f\n", +"f1=w1/(2*%pi);\n", +"f2=w2/(2*%pi);\n", +"f3=w3/(2*%pi);\n", +"fm=f2;//fm = maximum frquency is present at the signal\n", +"disp(f2,'maximum frquency of the signal is');\n", +"disp(' Hz');\n", +"fs=2*fm;//Nyquist rate\n", +"disp('Nquist Rate of Signal is');\n", +"disp(' Hz',fs);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.2: Nquist_Rate_and_time_interval.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Nquist Rate,time interval\n", +"//Example 3.2 \n", +"//page no 103\n", +"//Find Nquist Rate and Nquist time interval\n", +"//given\n", +"clc;\n", +"clear;\n", +"w1=5000*%pi;\n", +"w2=3000*%pi;\n", +"f1=w1/(2*%pi);\n", +"f2=w2/(2*%pi);\n", +"fm=f1;//fm = maximum frquency is present at the signal\n", +"disp(' Hz',f1,'i) maximum frquency of the signal is');\n", +"\n", +"fs=2*fm;//Nyquist rate\n", +"disp(' Hz',fs,'ii) Nquist Rate of the given Signal is');\n", +"Ts=1/(2*fm);//frequncy =1/time\n", +"disp('m Sec',Ts*10^3,'iii) Nquist Interval of the given signal is');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.3: Nquist_Rate.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"////Caption Nquist Rate \n", +"//Example 3.3 \n", +"//page no 104\n", +"//Find Nquist Rate \n", +"//given\n", +"clc;\n", +"clear;\n", +"f=100;\n", +"fs=2*f;//Nyquist rate\n", +"disp(' Hz',fs,'(i)To avoid aliasing Nquist Rate is '); " + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.4: Nquist_Rate.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Nquist Rate\n", +"//Example 3.4 \n", +"//page no 105\n", +"//Find Nquist Rate of Continous signal\n", +"//given\n", +"clc;\n", +"clear;\n", +"\n", +"w1=50*%pi;\n", +"w2=300*%pi;\n", +"w3=100*%pi;\n", +"f1=w1/(2*%pi);\n", +"f2=w2/(2*%pi);\n", +"f3=w3/(2*%pi);\n", +"fmax=f2;//fmax = Highest frquency component of the message signal\n", +"disp('Highest frquency component of the message signal will be');\n", +"disp(fmax,'fmax=');\n", +"disp(' Hz');\n", +"fs=2*fmax;//Nyquist rate\n", +"disp('Nquist Rate of the given Signal is');\n", +"disp(' Hz',fs);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.7: Amplitude.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//caption: amplitude\n", +"//Example 3.7 \n", +"//page no 123\n", +"//find amplitude distortion at highest frquency\n", +"//given\n", +"clc;\n", +"clear;\n", +"\n", +"fs=9.5; //samplig frequncy\n", +"fmax=1; //maximum frequncy\n", +"t=0.2; //pulse width\n", +"c=3*10^8;\n", +"f=fmax;\n", +"H1=t*sinc(f*t); //aperture effect at highest frequency\n", +"disp(H1*100,'|H(1)|=');\n", +"disp('%');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.8: Transmission_Bandwidth.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Transmission Bandwidth\n", +"//Example 3.8 \n", +"//page no 131\n", +"//Calculate Transmission Bandwidth\n", +"//given\n", +"clc;\n", +"clear;\n", +"\n", +"fm=3*10^3;\n", +"fs=8*10^3;// sampling frequncy\n", +"Ts=1/fs;\n", +"t=0.1*Ts;\n", +"BW=1/(2*t);//Bandwidth\n", +"disp('Transmission Bandwidth of PAM signal is ');\n", +"disp('kHz',BW*10^-3,'BW>=');\n", +"" + ] + } +], +"metadata": { + "kernelspec": { + "display_name": "Scilab", + "language": "scilab", + "name": "scilab" + }, + "language_info": { + "file_extension": ".sce", + "help_links": [ + { + "text": "MetaKernel Magics", + "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md" + } + ], + "mimetype": "text/x-octave", + "name": "scilab", + "version": "0.7.1" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/Digital_Communications_by_S_Sharma/4-WAVEFORM_CODING_TECHNIQUES.ipynb b/Digital_Communications_by_S_Sharma/4-WAVEFORM_CODING_TECHNIQUES.ipynb new file mode 100644 index 0000000..3be2cf7 --- /dev/null +++ b/Digital_Communications_by_S_Sharma/4-WAVEFORM_CODING_TECHNIQUES.ipynb @@ -0,0 +1,1297 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 4: WAVEFORM CODING TECHNIQUES" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.10: noise_ratio_and_required_bits.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption :noise ratio,required bits\n", +"//Example 4.10\n", +"//page no 173\n", +"//find i)noise ratio ii)bits\n", +"clc;\n", +"clear;\n", +"//Given data\n", +"Am=3;\n", +"v=10;\n", +"SNR=1.8+6*v;//noise ratio \n", +"disp(SNR,'Signal to Quantization noise ratio');\n", +"disp('dB.');\n", +"SN=40;\n", +"v=(SN-1.8)/6;\n", +"\n", +"disp('bits required to get signal to niose ratio of 40dB',ceil(v));" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.11: Maximum_frequency.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption :Maximum frequency\n", +"//Example 4.11\n", +"//page no 174\n", +"//find Maximum frequency\n", +"clc;\n", +"clear;\n", +"//Given data\n", +"v=7;\n", +"SNR=1.8+6*v;\n", +"r=56*10^3;\n", +"fs=r/v;//r=v*fs signaling rate\n", +"fm=fs/2;//Nquset rate\n", +"disp(fm/10^3,'Maximum frequency is');\n", +"disp('kHz');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.13: Maximum_Amplitude.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Maximum Amplitude\n", +"//Example 4.13\n", +"//page no 185\n", +"//Find Maximum Amplitude\n", +"clear;\n", +"clc;\n", +"fm=3*10^3;\n", +"Nyquistrate=2*fm;//Nyquistrate\n", +"fs=5*Nyquistrate;//Samplingfrquency\n", +"Ts=1/fs;// Sampling Interval\n", +"del=0.25;//step size\n", +"fm1=2*10^3;\n", +"Am=del/(2*%pi*fm1*Ts);\n", +"disp('Volts',Am,'Maximum Amplitude ');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.14: Signaling_rate.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: signaling rate\n", +"//Example 4.14\n", +"//page no 187\n", +"//Find signaling rate\n", +"clear;\n", +"clc;\n", +"fs1=8*10^3;\n", +"del=31.25*10^-3;\n", +"q=64;\n", +"v=log2(q);\n", +"r=v*fs1;//signaling rate\n", +"disp(r*10^-3,'i)Signaling rate of PCM is');\n", +"disp('kHz');\n", +"\n", +"fm=3*10^3;\n", +"A=1;\n", +"fs2=(2*%pi*fm*A)/(del);\n", +"disp(fs2*10^-3,'ii)The signaling rate of DM is');;\n", +"disp('kHz');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.15: Signal_to_noise_ratio.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Signal to noise ratio\n", +"//Example 4.15\n", +"//page no 188\n", +"//Find signal to noise ratio\n", +"clear;\n", +"clc;\n", +"fs=64*10^3;\n", +"fm=2*10^3;\n", +"fM=4*10^3;\n", +"SNR=(3*fs^3)/(8*%pi^2*fm^2*fM);// Signal to noise ratio\n", +"SNRO=10*log10(SNR)\n", +"disp('dB',SNRO,'Output signal to noise ratio =');\n", +" " + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.16: Signal_to_Quatization_noise_ratio.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Signal to Quatization noise ratio\n", +"//Example 4.16\n", +"//page no 188\n", +"//Find signal to Quatization noise ratio \n", +"clear;\n", +"clc;\n", +"\n", +"fs=8*10^3;\n", +"r=64*10^3;\n", +"N=8;//number of bits\n", +"SNR=(1.8+6*N);//signal to Quatization noise ratio\n", +"disp(SNR,'Signal to Quatization noise ratio of PCM system is')\n", +"disp('dB');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.17: sampling_rate_and_quantizing_level.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: sampling rate,quantizing level\n", +"//Example 4.17\n", +"//page no 194\n", +"//Find sampling rate,quantizing level\n", +"clear;\n", +"clc;\n", +"r=36000;\n", +"fm=3.2*10^3;\n", +"fs=2*fm;//Nquest rate\n", +"\n", +"v=r/fs; //r=v*fs signaling rate\n", +"v=floor(v);\n", +"q=2^v;\n", +"fs1=r/v;\n", +"disp(q,'quantizing level q=');\n", +"disp(fs1/1000,'sampling rate fs=');\n", +"disp('kHz');\n", +"disp(v,'Number of binary digits =')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.18: time_duration_of_binary_signal.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: time duration of binary signal\n", +"//Example 4.18\n", +"//page no 196\n", +"//Find time duration of 1bit binary encoded signal\n", +"clear;\n", +"clc;\n", +"fs=input('Enter the Nyquist rate of Signal fs(Hz)=');\n", +"q=input('Enter the Quantization levels q =');\n", +"\n", +"v=log2(q);//binary pulses transmitted per second\n", +"t=1/(v*fs);//Nyquist interval\n", +"disp(' sec',t,' Time duration of binary signal t=');\n", +"//output\n", +"//Enter the Nyquist rate fs(Hz)=3\n", +"//Enter the Quantization levels q =5\n", +" \n", +" // time duration of 1bit binary signal \n", +" \n", +" // t=0.1435589 sec\n", +" " + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.20: Quantizing_noise_ratio.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"\n", +"//Caption: Quantizing noise ratio\n", +"//Example 4.20\n", +"//page no 196\n", +"//find signal to noise ratio\n", +"clc;\n", +"clear;\n", +"\n", +"SNR=40;\n", +"SNRO=10^(SNR/10);\n", +"//SNR=3(q^2)/2, Signal to Quantization noise ratio\n", +"q=sqrt((2*SNRO)/3);\n", +"q=ceil(q);\n", +"v=log2(q);//q=2^v Quantization levels\n", +"v=ceil(v);\n", +"snr=1.76+6.02*v;//output Signal to Quantization noise ratio\n", +"disp('dB',snr,'Output Signal to Quantization noise ratio')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.21_ii: Bandwidth.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Bandwidth\n", +"//Example 4.21.i\n", +"//page no 197\n", +"//Find minimum required bandwidth\n", +"clear;\n", +"clc;\n", +"SNRO=30;//dB\n", +"fmin=300;\n", +"fmax=3300;\n", +"fs=8000;\n", +"v=5;\n", +"fPCM=(v*fs)/2;\n", +"disp(fPCM/1000,'minimum required bandwidth');\n", +"disp('kHz');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.21_iii: Quantizing_levels_bits_per_sample_and_Bandwidth.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Quantizing levels,bits per sample,Bandwidth\n", +"//Example 4.21.iii\n", +"//page no 197\n", +"//Find Quantizing levels,minimum number of bits per sample and bandwidth\n", +"clear;\n", +"clc;\n", +"SNRO=30;//dB\n", +"fmin=300;\n", +"fmax=3300;\n", +"fs=8000;\n", +"\n", +"q=10^((SNRO+10.1)/20);\n", +"q=ceil(q);\n", +"v=log2(q);\n", +"v=ceil(v);\n", +"disp(q,'Quantizing levels need is');\n", +"disp(v,'minimum number of bits per sample is');\n", +"\n", +"\n", +"fPCM=(v*fs)/2;\n", +"disp(fPCM/1000,'minimum required bandwidth');\n", +"disp('kHz');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.21_i: Quantizing_levels_and_bits_per_sample.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption:Quantizing levels, bits per sample\n", +"//Example 4_21.i\n", +"//page no 197\n", +"//Find Quantizing levels,minimum number of bits per sample\n", +"clear;\n", +"clc;\n", +"SNRO=30;//dB\n", +"fmin=300;\n", +"fmax=3300;\n", +"fs=80000;\n", +"//SNRO=1.76+20log10(q)\n", +"q=10^((SNRO-1.76)/20);\n", +"q=ceil(q);\n", +"v=log2(q);\n", +"disp(q,'Quantizing levels required is');\n", +"disp(ceil(v),'minimum number of bits per sample are');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.24: Maximum_Amplitude_and_SNR.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Maximum Amplitude,SNR\n", +"//Example 4.24\n", +"//page no 199\n", +"//determine the Maximum Amplitude,\n", +"// \n", +"clear;\n", +"clc;\n", +"del=250*10^-3;\n", +"wm=2*%pi*1000; \n", +"fs=3*10^3;\n", +"Ts=1/fs\n", +"\n", +"Amax=(del*3*fs*2)/(wm);//Amplitude\n", +"disp('V',Amax,'Maximum Amplitude,');\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.26: Bits_per_sample.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption:Bits per sample\n", +"//Example 4.26\n", +"//page no 200\n", +"//Find number of bits per sample\n", +"clear;\n", +"clc;\n", +"SNR=20;//dB\n", +"averagepower=30*10^-3;\n", +"SNRO=10^(SNR/10);//dB\n", +"A=3.8;\n", +"//L=2^n\n", +"//SNRO=average signal power/Quatizing power\n", +"//del=(2*A)/L\n", +"L=sqrt((SNRO*A^2)/(3*averagepower));\n", +"n=log2(L);\n", +"n=ceil(n);\n", +"disp(n,'Bits required per sample');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.27_ii: Bit_transmission_rate.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Bit transmission rate\n", +"//Example 4.27.ii\n", +"//page no 200\n", +"//Find bit transmission rate\n", +"clear;\n", +"clc;\n", +"fm=3*10^3;\n", +"v=8;\n", +"VH=5;\n", +"VL=-5;\n", +"q=2^v;\n", +"\n", +"fs=2*fm; //Nyquist rate\n", +"r=8*fs;\n", +"disp('K bits/s',r/1000,'bit transmission rate');\n", +" " + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.27_iii: SNR.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: SNR\n", +"//Example 4.27.i\n", +"//page no 200\n", +"//Find Signal to quantization noise ratio\n", +"clear;\n", +"clc;\n", +"Nq=127.15*10^-6\n", +"Meansignal=2;\n", +"P=Meansignal/1;\n", +"SNR=P/Nq;\n", +"SNRq=10*log10(SNR);\n", +"disp('dB',SNRq,'Signal to quantization noise ratio');\n", +" " + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.27_i: Normalized_power.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption:Normalized power \n", +"//Example 4.27.i\n", +"//page no 200\n", +"//Find Normalized power for quantization noise\n", +"clear;\n", +"clc;\n", +"fm=3*10^3;\n", +"v=8;\n", +"VH=5;\n", +"VL=-5;\n", +"q=2^v;\n", +"del=(VH-VL)/q;\n", +"Nq=del^2/12;//quantization noise\n", +"disp('W',Nq,'Normalized power for quantization noise')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.28: SNR_bitrate_and_no_of_bits_recorded.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: SNR,bitrate,no.of bits recorded\n", +"//Example 4.28\n", +"//page no 201\n", +"//Find i)SNR ii)output bit rate iii)no.of bits recorded\n", +"clear;\n", +"clc;\n", +"N=16;\n", +"v=16;\n", +"fs=44.1*10^3;\n", +"SNR=1.76+6*N;\n", +"disp('dB',SNR,'i)Out put signal noise ratio');\n", +"bitrate=2*v*fs;\n", +"outputbitrate=2*bitrate;//including addtional 100% over head\n", +"disp('Mbits/sec',outputbitrate*10^-6,'ii)output bit rate');\n", +"CD=outputbitrate*3600;\n", +"disp('gigabits',CD*10^-9,'iii)no.of bits recorded in CD');\n", +" " + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.29: output_SNR.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: output SNR\n", +"//Example 4.29\n", +"//page no 202\n", +"//Find output SNR\n", +"clear;\n", +"clc;\n", +"fm=1*10^3;\n", +"fs=32*10^3;\n", +"FM=4*10^3;// Bandwidth\n", +"SNR=(3*fs^3)/(8*%pi^2*fm^2*FM);//SNR\n", +"SNRO=10*log10(SNR);\n", +"disp('dB',SNRO,'Output signal to noise ratio');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.2_i: code_word_length.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption:code word length\n", +"//Example 4.2.i\n", +"//page no 167\n", +"//find code word length\n", +"clc;\n", +"clear;\n", +"//Given data\n", +"bandwidth=4.2*10^6;\n", +"fm=bandwidth;\n", +"q=512// Quantization levels\n", +"//q=2^v\n", +"v=log10(512)/log10(2);\n", +"disp(v,'The code word legth is ');\n", +"disp('bits');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.2_iii: Final_Bit_rate.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Final Bit rate\n", +"//Example 4.2.iii\n", +"//page no 167\n", +"//find Final Bit rate\n", +"clc;\n", +"clear;\n", +"//Given data\n", +"bandwidth=4.2*10^6;\n", +"fm=bandwidth;\n", +"q=512// Quantization levels\n", +"v=9;\n", +"fs=2*fm;\n", +"r=v*fs;//signaling rate\n", +"disp(r,'Final Bit rate ');\n", +"disp('bits/sec');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.2_ii: Transmission_Bandwidth.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Transmission Bandwidth\n", +"//Example 4.2.ii\n", +"//page no 167\n", +"//find The transmission Bandwidth\n", +"clc;\n", +"clear;\n", +"//Given data\n", +"bandwidth=4.2*10^6;\n", +"fm=bandwidth;\n", +"q=512// Quantization levels\n", +"v=9;\n", +"bw=v*fm;\n", +"disp(bw*10^-6,'The transmission Bandwidth is ');\n", +"disp('MHz');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.2_iv: Output_signal_to_noise_ratio.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Output signal to noise ratio\n", +"//Example 4.2.iv\n", +"//page no 167\n", +"//find Output signal to noise ratio\n", +"clc;\n", +"clear;\n", +"//Given data\n", +"bandwidth=4.2*10^6;\n", +"fm=bandwidth;\n", +"q=512// Quantization levels\n", +"v=9;\n", +"sn=4.8+6*v;//noise in dB\n", +"disp(sn,'Output signal to noise ratio is');\n", +"disp('dB');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.30_iii: Signal_to_Noise_Ratio.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: SNR\n", +"//Example 4.30iii\n", +"//page no 202\n", +"//Find SNR\n", +"clear;\n", +"clc;\n", +"fs=64000;\n", +"Amax=1;\n", +"fm=3500;\n", +"Nqd=2.1522995*10^-3;\n", +"So=Amax^2/2;\n", +"SNR=So/Nqd;\n", +"SNRO=10*log10(SNR);\n", +"disp('dB',SNRO,'Output signal noise ratio');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.30_ii: Noise_power.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: noise power\n", +"//Example 4.30ii\n", +"//page no 202\n", +"//Find Quantizatio noise power \n", +"clear;\n", +"clc;\n", +"fs=64000;\n", +"Amax=1;\n", +"fm=3500;\n", +" del=343.6117*10^-3;//step size\n", +" Nq=del^2/3;//Quantizatio noise power\n", +" Nqd=Nq*(fm/fs);\n", +"disp('mW',Nqd*1000,'Quantizatio noise power ');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.30_i: step_size.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: step size\n", +"//Example 4.30i\n", +"//page no 202\n", +"//Find step size\n", +"clear;\n", +"clc;\n", +"fs=64000; // samples/sec\n", +"Amax=1;\n", +"fm=3500;\n", +"//A=del/(2*%pi*fm*Ts)\n", +"del=(2*%pi*fm*Amax)/fs;\n", +"disp('mV',del*1000,'Step Size ');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.31: number_of_bits_per_sec.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: no.of bits/sec\n", +"//Example 4.31\n", +"//page no 203\n", +"//Find no.of bits/sec\n", +"//assuming signal is sampled at the rate 20% above Nyquist rate\n", +"clear;\n", +"clc;\n", +"fm=4.5*10^6;\n", +"q=1024;\n", +"fs=1.2*2*fm;//20% above Nyquist rate\n", +"v=log2(q);\n", +"r=v*fs;\n", +"disp('M bit/sec',r/10^6,'no.of bits/sec');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.32: step_size_noise_power_and_SNR.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: step size,noise power, SNR\n", +"//Example 4.32\n", +"//page no 203\n", +"//Find step size,noise power, SNR\n", +"//assume bandwidth of the singal is 4kHz\n", +"clear;\n", +"clc;\n", +"fs=32000;\n", +"A=2;\n", +"fm=4000;\n", +"BW=4000;\n", +"del=(2*%pi*fm*A)/fs;\n", +"disp('Volt',del,'i)step size');\n", +"Nq=del^2/3\n", +"disp('W',Nq,'ii)noise power');\n", +"SNR=(3*fs^3)/(8*%pi^2*fm^2*BW);\n", +"disp(SNR,'iii)SNR=');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.33: signaling_rate_and_bandwidth.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: signaling rate, bandwidth\n", +"//Example 4.33\n", +"//page no 204\n", +"//Find signaling rate, bandwidth\n", +"//assuming signal is sampled at the rate 20% above Nyquist rate\n", +"clear;\n", +"clc;\n", +"fm=15*10^3;\n", +"fs=1.2*2*fm;\n", +"q=65536;\n", +"v=log2(q);\n", +"r=v*fs;\n", +"disp('i)signaling rate,')\n", +"disp('K bits/sec',r/1000,'r=');\n", +"BW=r/2;\n", +"disp('ii)bandwidth')\n", +"disp('kHz',BW/1000,'BW min=')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.34: Step_size_and_Noise_power.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: step size,noise power\n", +"//Example 4.34\n", +"//page no 204\n", +"//Find step size,noise power\n", +"clear;\n", +"clc;\n", +"fs=64*10^3;\n", +"fm=3500;\n", +"A=1;\n", +"del=(2*%pi*fm*A)/fs;//step size\n", +"disp('Volts',del,'i)step size');\n", +"Nq=(del^2/3)*(fm/fs);//Granular noise power\n", +"disp('W',Nq,'ii)Nq=');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.3_i: bits_per_sample.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption :bits per sample\n", +"//Example 4.3.i\n", +"//page no 168\n", +"//find bits per sample\n", +"clc;\n", +"clear;\n", +"//Given data\n", +"fmax=4*10^3;\n", +"xmax=3.8;\n", +"snr=100;\n", +"P=30*10^-3;\n", +"v=(log10(((snr*xmax^2)/(3*P)))/(2*log10(2)));\n", +"disp(ceil(v),'Number of bits required per sample are');\n", +"disp('bits');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.3_ii: Transmission_Bandwith.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Transmission Bandwith\n", +"//Example 4.3.ii\n", +"//page no 168\n", +"//Find Transmission Bandwith\n", +"clc;\n", +"clear;\n", +"//Given data\n", +"fm=4*10^3;//Bandwidth of PCM\n", +"xmax=3.8;\n", +"snr=100;// Signal to Noise Ratio\n", +"outputs=30;\n", +"v=7;\n", +"bw=outputs*v*fm;\n", +"r=bw*2;\n", +"disp(bw/10^3,'Transmission Bandwith');\n", +"disp('kHz');\n", +"disp('bits/sec',r/1000,'Signaling rate')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.4: samplingrate_bandwidth_and_bitrate.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: samplingrate,number of bits,bitrate,bandwidth\n", +"//Example 4.4\n", +"//page no 169\n", +"//find sampling rate,number of bits,bit rate,bandwidht\n", +"clc;\n", +"clear;\n", +"//Given data\n", +"emax=0.001;\n", +"del=2*emax;;\n", +"fm=100;\n", +"xmax=10;\n", +"\n", +"q=(2*xmax)/del;\n", +"fs=2*fm;\n", +"v=(log10(q))/log10(2);\n", +"v=ceil(v);\n", +"r=v*fs;\n", +"disp(fs,'i)sampling Frequncy');\n", +"disp('Hz.');\n", +"disp(v,'ii)no.of bits in PCM');\n", +"disp('bits.');\n", +"disp(r,'iii)sampling rate');\n", +"disp('bits per second.');\n", +"disp(r/2,'iv)Transmission Bandwidth');\n", +"disp('Hz.');\n", +"\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.5: Bandwidth_and_Sampling_Rate.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Bandwidth,Sampling Rate\n", +"//Example 4.5\n", +"//page no 170\n", +"//Find Bandwidth,Sampling Rate\n", +"clc;\n", +"clear;\n", +"//Given data\n", +"fm=3.4*10^3;\n", +"N=24;\n", +"r=1.5*10^6;\n", +"encoder=8;\n", +"\n", +"BW=N*fm;\n", +"disp(BW/10^3,'Channel Bandwith is');\n", +"disp('kHz');\n", +"\n", +"r1=r/N;\n", +"fs=r1/encoder;\n", +"\n", +"disp(fs,'sampling frequency');\n", +"disp('Hz or samples per second.');\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.6: Signal_Bandwidth_and_Noise_Ratio.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Signal Bandwidth,Noise Ratio\n", +"//Example 4.6\n", +"//page no 170\n", +"//Find Signal Bandwidth,Noise Ratio\n", +"clc;\n", +"clear;\n", +"//Given data\n", +"v=7;\n", +"r=50*10^6;\n", +"//fs=2*fm\n", +"fm=r/(2*v);\n", +"disp(fm*10^-6,'Maximum message Bandwidth is ');\n", +"disp('MHz');\n", +"\n", +"snr=1.8+(6*v);\n", +"disp(snr,'signal to quantization niose ration');\n", +"disp('dB');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.7: Bitspersample_and_Transmissionrate.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: bitspersample,Transmissionrate\n", +"//Example 4.7\n", +"//page no 171\n", +"//find i)bits per sample,ii)transmission rate\n", +"clc;\n", +"clear;\n", +"//Given data\n", +"fm=3*10^3;\n", +"q=16;\n", +"\n", +"v=(log10(q))/log10(2);\n", +"disp(v,'bits in code word');\n", +"disp('bits');\n", +"fs=2*fm;\n", +"r=v*fs;\n", +"disp(r,'bit trasmission rate');\n", +"disp('bits per second')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.8: signal_to_noise_ratio.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption:signal to noise ratio\n", +"//Example 4.8\n", +"//page no 171\n", +"//find signal to noise ratio\n", +"clc;\n", +"clear;\n", +"//Given data\n", +"fm=3.5*10^3;\n", +"r=50*10^3;\n", +"fs=2*fm;\n", +"rms=0.2;\n", +"xmax=2;\n", +"v=r/fs;//signaling rate r=v*fs\n", +"v=ceil(v);\n", +"P=(rms^2)/1;\n", +"SNR=((3*P*2^(2*v))/(xmax^2));\n", +"SN=10*log10(SNR);\n", +"disp(ceil(SN),'signal to niose ratio');\n", +"disp('dB');" + ] + } +], +"metadata": { + "kernelspec": { + "display_name": "Scilab", + "language": "scilab", + "name": "scilab" + }, + "language_info": { + "file_extension": ".sce", + "help_links": [ + { + "text": "MetaKernel Magics", + "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md" + } + ], + "mimetype": "text/x-octave", + "name": "scilab", + "version": "0.7.1" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/Digital_Communications_by_S_Sharma/5-DIGITAL_MULTIPLEXERS.ipynb b/Digital_Communications_by_S_Sharma/5-DIGITAL_MULTIPLEXERS.ipynb new file mode 100644 index 0000000..cff7089 --- /dev/null +++ b/Digital_Communications_by_S_Sharma/5-DIGITAL_MULTIPLEXERS.ipynb @@ -0,0 +1,165 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 5: DIGITAL MULTIPLEXERS" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5.1: Sampling_Rate.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Sampling Rate\n", +"//Example 5.1\n", +"//page no 220\n", +"//Find Sampling Rate\n", +"clear;\n", +"clc;\n", +"f1=4*10^3;\n", +"f2=4.5*10^3;\n", +"fsmin=2*f2;\n", +"disp('kHz',fsmin/1000,'Sampling rate');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5.2: Nyquest_rate_Signaling_rate_and_bandwidth.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Nyquest rate,Signaling rate,bandwidth\n", +"//Example 5.2\n", +"//page no 220\n", +"//Find i)Nyquest rate,\n", +"// iii)Signaling rate,\n", +"// iv)bandwidth\n", +"clc;\n", +"clear;\n", +" \n", +"f1=3000;\n", +"f4=1000;\n", +"f2=1000;\n", +"f3=1000;\n", +"//Nyquest rate\n", +"nq1=2*f1;\n", +"nq2=2*f2;\n", +"nq3=2*f3;\n", +"nq4=2*f4;\n", +"disp('kHz',nq1,'i)Nyquest rate of x1');\n", +"disp('kHz',nq2,' Nyquest rate of x2');\n", +"disp('kHz',nq3,' Nyquest rate of x3');\n", +"disp('kHz',nq4,' Nyquest rate of x4');\n", +"r=nq1+nq2+nq3+nq4;\n", +"disp('Samples/sec',r,'iii)Signaling rate');\n", +"bw=r/2;\n", +"disp('Hz',bw,'iv)Minimum channel bandwidth');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5.3: spacing_distance.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: spacing distance\n", +"//Example 5.3\n", +"//page no 221\n", +"//Find The spacing between two successive pules\n", +"clc;\n", +"clear;\n", +"samplingrate=8000;\n", +"totalsignals=24+1;\n", +"t=1/samplingrate;\n", +"T=t/totalsignals;\n", +"T=T*10^6//time is now u sec\n", +"space=T-1;\n", +"disp('u sec',space,'The spacing between two successive pules');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5.4: signaling_rate_and_bandwidth.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: signaling rate ,bandwidth\n", +"//Example 5.4\n", +"//page no 222\n", +"//Find signaling rate ,bandwidth\n", +"clc;\n", +"clear;\n", +"N=6;\n", +"fm=5000;\n", +"r=2*fm;//sampling rate\n", +"sr=N*r;//signalingrate\n", +"disp('K bits/sec',sr/1000,'Signaling rate');\n", +"BW=N*fm;//Bandwith\n", +"disp('kHz',BW/1000,'Bandwith to avoid the cross talk in TDM is');" + ] + } +], +"metadata": { + "kernelspec": { + "display_name": "Scilab", + "language": "scilab", + "name": "scilab" + }, + "language_info": { + "file_extension": ".sce", + "help_links": [ + { + "text": "MetaKernel Magics", + "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md" + } + ], + "mimetype": "text/x-octave", + "name": "scilab", + "version": "0.7.1" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/Digital_Communications_by_S_Sharma/6-DIGTIAL_BASEBAND_TRANSMISSION.ipynb b/Digital_Communications_by_S_Sharma/6-DIGTIAL_BASEBAND_TRANSMISSION.ipynb new file mode 100644 index 0000000..82eee29 --- /dev/null +++ b/Digital_Communications_by_S_Sharma/6-DIGTIAL_BASEBAND_TRANSMISSION.ipynb @@ -0,0 +1,95 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 6: DIGTIAL BASEBAND TRANSMISSION" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6.25: roll_of_factor.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: roll of factor\n", +"//Example 6.25\n", +"//page no 307\n", +"//Find The roll of factor alpha\n", +"clc;\n", +"clear;\n", +"datarate=0.1*10^6;\n", +"fB=75000; //bandwidth\n", +"Tb=1/datarate;\n", +"alpha=2*fB*Tb-1\n", +"disp(alpha,'factor alpha = ')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6.26: Transmission_bandwidth.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Transmission bandwidth\n", +"//Example 6.26\n", +"//page no 307\n", +"//Find The Transmission bandwidth\n", +"clc;\n", +"clear;\n", +"q=128;\n", +"alpha=0.2\n", +"n=log2(q);\n", +"fm=2000;\n", +"Nq=2*fm;\n", +"fs=1.25*Nq;\n", +"N=8;\n", +"total=N*fs;\n", +"bitrate=7*total;\n", +"fB=((1+alpha)*bitrate)/2;\n", +"disp('kHz',fB/1000,'Transmission Bandwidth');" + ] + } +], +"metadata": { + "kernelspec": { + "display_name": "Scilab", + "language": "scilab", + "name": "scilab" + }, + "language_info": { + "file_extension": ".sce", + "help_links": [ + { + "text": "MetaKernel Magics", + "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md" + } + ], + "mimetype": "text/x-octave", + "name": "scilab", + "version": "0.7.1" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/Digital_Communications_by_S_Sharma/8-DIGITAL_MODULATION_TECHNIQUES.ipynb b/Digital_Communications_by_S_Sharma/8-DIGITAL_MODULATION_TECHNIQUES.ipynb new file mode 100644 index 0000000..70d2d13 --- /dev/null +++ b/Digital_Communications_by_S_Sharma/8-DIGITAL_MODULATION_TECHNIQUES.ipynb @@ -0,0 +1,311 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 8: DIGITAL MODULATION TECHNIQUES" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.10: probability_of_error.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: probability of error\n", +"//Example 8.10\n", +"//page no 382\n", +"//Find probability of error of FSK\n", +"clc;\n", +"clear;\n", +"rb=300;//bit rate\n", +"T=1/rb;\n", +"A2N0=8000;\n", +"//Pe=1/2*exp(-Eb/2N0);\n", +"//Eb=A^2*T/2\n", +"Pe=1/2*exp(-((A2N0*T)/4));//Probability of error non coherent FSK\n", +"disp(Pe,'Probability of error is ');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.11: probability_of_symbol_error.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: probability of symbol error\n", +"//Example 8.11\n", +"//page no 383\n", +"//Find probability of symbol error \n", +"//assuming coherent detection\n", +"clc;\n", +"clear;\n", +"rb=2.5*10^6//binary data rate\n", +"N0=2*10^-20;//power spectral density of noise FSK system\n", +"A=1*10^-6;//amplitude of received signal\n", +"T=1/rb;\n", +"Eb=(A^2*T)/2;// Eb=bit energy\n", +"z=sqrt(Eb/(2*N0))\n", +"Pe=1/2*erfc(z);//probability of symbol error\n", +"disp(Pe,'probability of symbol error');//" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.1: probability_of_error.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"\n", +"//Caption: probability of error\n", +"//Example 8.1\n", +"//page no 374\n", +"//Find probability of bit error \n", +"//AWGN is added to signal\n", +"clc;\n", +"clear;\n", +"N0=2*10^-15;\n", +"Ps1=1/2;\n", +"Ps2=1/2;\n", +"A=0.2*10^-3;\n", +"T=2*10^-6;\n", +"\n", +"Eb=(A/sqrt(2))^2*T*Ps1+Ps2*0^2;//Eb=bit energy\n", +"z=sqrt(Eb/N0);//Probability \n", +"disp(z,'z = ');\n", +"//Pe=(8)*10^(-4)//probability of error from the table\n", +"Pe=1/2*erfc(z/sqrt(2));\n", +"disp('probability of bit error when P(s1)=P(s2)=1/2 ');\n", +"disp(Pe,'P(e)=');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.2: peak_Amplitude.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: peak Amplitude\n", +"//Example 8.2\n", +"//page no 374\n", +"//Find peak Transmission pulseAmplitude\n", +"clc;\n", +"clear;\n", +"NO=1.338*10^-5;\n", +"Pe=2.055*10^-5;\n", +"T=100*10^-6;\n", +"//Pe=erfc(sqrt(Eb/(2*N0)));\n", +"Eb=(2*2.9^2*NO);\n", +"A=sqrt((Eb*2)/T);\n", +"disp('Volts',A,'Transmission pulse Amplitude');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.4: probability_of_error.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: probability of error\n", +"//Example 8.4\n", +"//page no 377\n", +"//Find probability of error\n", +"clc;\n", +"clear;\n", +"A=1*10^-3;\n", +"Tb=0.2*10^-3;\n", +"fb=1/Tb;\n", +"fc=5*fb;\n", +"N0=2*10^-11;// power sepctral density\n", +"\n", +"Eb=(A^2*Tb)/2;//Eb=bit energy\n", +"\n", +"\n", +"z=sqrt(Eb/N0);\n", +"Pe=erfc(z)'//bit error probability\n", +"disp('Error probability of PSK is ')\n", +"disp(Pe,'P(e) =');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.5: probability_bit_error.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: probability bit error\n", +"//Example 8.5\n", +"//page no 378\n", +"//Find bit error probability \n", +"clc;\n", +"clear;\n", +"A=10*10^-3;\n", +"T=10^-6;\n", +"N0=10^-11;// power sepctral density\n", +"\n", +"Eb=(A^2*T)/2//Eb=bit energy\n", +"\n", +"z=sqrt(Eb/N0);//Probability of ASK\n", +"Pe=erfc(z)'//bit error probability\n", +"disp('bit error probability ')\n", +"disp(Pe,'Pe =')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.7: Amplitude.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: amplitude\n", +"//Example 8.7\n", +"//page no 379\n", +"//Find carrier amplitude\n", +"clc;\n", +"clear;\n", +"Pe=10^-4;//probability of error of PSK\n", +"N0=2*10^-10;\n", +"//from table error function \n", +"//Pe=erffc(z)\n", +"z=2.6\n", +"r=10^6;\n", +"T=1/r;\n", +" //z=sqrt(Eb/N0)\n", +"Eb=N0*z^2; // Eb=bit energy\n", +"A=sqrt((Eb*2)/T); //Eb=A^2*T/2\n", +"disp('mV',A*1000,'Carrier Amplitude');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.8: Carrier_power_and_Bandwidth.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"\n", +"//Caption: Carrier power\n", +"//Example 8.8\n", +"//page no 382\n", +"//Find Carrier power,Bandwidth\n", +"clc;\n", +"clear;\n", +"Pe=10^-4;//probability of error of FSK\n", +"r=1*10^6//tranasmitted rate\n", +"N0=1*10^-7;//psd at input of the receiver\n", +"//from table error function \n", +"//Pe=erffc(z)\n", +"z=3.71\n", +"T=1/r;\n", +" //z=sqrt(Eb/N0)\n", +"//Eb=N0*z^2; // Eb=bit energy\n", +"Ac=sqrt((z^2*2*N0)/T);\n", +"\n", +"AP=(Ac/sqrt(2))^2;//average carrier power\n", +"disp('watts',AP,'Average carrier power =');\n", +"BW=1/T;\n", +"disp('MHz',BW*10^-6,'Channel Bandwidth =');" + ] + } +], +"metadata": { + "kernelspec": { + "display_name": "Scilab", + "language": "scilab", + "name": "scilab" + }, + "language_info": { + "file_extension": ".sce", + "help_links": [ + { + "text": "MetaKernel Magics", + "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md" + } + ], + "mimetype": "text/x-octave", + "name": "scilab", + "version": "0.7.1" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/Digital_Communications_by_S_Sharma/9-INFORMATION_THEORY.ipynb b/Digital_Communications_by_S_Sharma/9-INFORMATION_THEORY.ipynb new file mode 100644 index 0000000..2d7db91 --- /dev/null +++ b/Digital_Communications_by_S_Sharma/9-INFORMATION_THEORY.ipynb @@ -0,0 +1,988 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 9: INFORMATION THEORY" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.12: rate_of_information.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: rate of information\n", +"//Example 9.12\n", +"//page no 401\n", +"//Find Average rate of information\n", +"clc;\n", +"clear;\n", +"m=16;\n", +"pxi=1/16;\n", +"elements=2*10^6;\n", +"n=32\n", +"HX=0;\n", +"for(i=1:16)\n", +" HX=HX+(-(pxi*log2(pxi)));\n", +"end\n", +"r=elements*n;\n", +"R=r*HX\n", +"printf('Average rate of information\n \n \t R = %d Mbs',R/10^6);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.13: information_rate.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: information rate\n", +"//Example 9.13\n", +"//page no 401\n", +"//Find information rate the telegraphic source\n", +"clc;\n", +"clear;\n", +"pdash=1/3;\n", +"pdot=2/3;\n", +"tdot=0.2;\n", +"tdash=0.6;\n", +"tspace=0.2;\n", +"HX=-pdash*log2(pdash)-pdot*log2(pdot);\n", +"Ts=pdot*tdot+pdash*tdash+tspace;\n", +"r=1/Ts;\n", +"R=r*HX;\n", +"printf('Average rate of information\n \n \t R = %.2f b/s',R);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.14: Information_rate.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: information rate\n", +"//Example 9.14\n", +"//page no 402\n", +"//Find information rate of the source\n", +"clc;\n", +"clear;\n", +"f=input('Enter the frequncy f=');\n", +"px1=1/8;\n", +"px2=1/8;\n", +"px3=3/8;\n", +"px4=3/8;\n", +"\n", +"HX=px1*log2(1/px1)+px2*log2(1/px2)+px3*log2(1/px3)+px4*log2(1/px4);//entropy of the source\n", +"R=2*f*HX;//r=2*f;\n", +"printf('information rate \n\n \t R= %.1f bits/sec ',R);//f=signal bandwidth" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.15: Information_rate.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: information rate\n", +"//Example 9.15\n", +"//page no 403\n", +"//Find information rate of the source\n", +"//all symbols are equally likely\n", +"clc;\n", +"clear;\n", +"px1=1/2;\n", +"px2=1/2;\n", +"px3=1/2;\n", +"px4=1/2;\n", +"f=input('Enter the frequncy of system fm(in Hz) =');\n", +"HX=px1*log2(1/px1)+px2*log2(1/px2)+px3*log2(1/px3)+px4*log2(1/px4);\n", +"\n", +"\n", +"printf('\n Entropy H(X) =%d bits/symbol\n ',HX);\n", +"R=2*f*HX;\n", +"printf('\n information rate =%d bits/sec',R);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.16: Entropy_and_information_rate.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: entropy ,information rate\n", +"//Example 9.16\n", +"//page no 404\n", +"//Find source entropy ,information rate\n", +"clc;\n", +"clear;\n", +"//probability symbols\n", +"px1=1/2;\n", +"px2=1/4;\n", +"px3=1/8;\n", +"px4=1/16;\n", +"px5=1/16;\n", +"Tb=10^-3;\n", +"HX=px1*log2(1/px1)+px2*log2(1/px2)+px3*log2(1/px3)+px4*log2(1/px4)+px5*log2(1/px5);\n", +"printf('i) source entropy\n\n \tH(X) = %.2f bits/symbol\n',HX);//source entropy\n", +"r=1/Tb;\n", +"R=r*HX;//information rate\n", +"printf('\n\n ii)information rate \n\n \t R = %d bits/sec',R);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.17: Entropy_and_information_rate.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"\n", +"//Caption: entropy and information rate\n", +"//Example 9.17\n", +"//page no 404\n", +"//determine entropy ,information rate\n", +"//assume if there are 16 outcomes per second\n", +"clc;\n", +"clear;\n", +"px1=1/2;\n", +"px2=1/4;\n", +"px3=1/8;\n", +"px4=1/16;\n", +"px5=1/16;\n", +"r=16\n", +"HX=px1*log2(1/px1)+px2*log2(1/px2)+px3*log2(1/px3)+px4*log2(1/px4)+px5*log2(1/px5);\n", +"\n", +"printf('i) Entropy\n\n \tH(X) = %.2f bits/symbol\n',HX);//source entropy\n", +"\n", +"R=r*HX;\n", +"printf('\n\n ii)information rate \n\n \t R = %d bits/sec',R);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.18: Entropy_and_information_rate.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"\n", +"//Caption: entropy ,information rate\n", +"//Example 9.18\n", +"//page no 405\n", +"//determine entropy ,information rate\n", +"clc;\n", +"clear;\n", +"px1=1/4;\n", +"px2=1/5;\n", +"px3=1/5;\n", +"px4=1/10;\n", +"px5=1/10;\n", +"px6=1/20;\n", +"px7=1/20;\n", +"px8=1/20;\n", +"f=10*10^3;\n", +"fs=10*2*10^3;\n", +"HX=px1*log2(1/px1)+px2*log2(1/px2)+px3*log2(1/px3)+px4*log2(1/px4)+px5*log2(1/px5)+px6*log2(1/px6)+px7*log2(1/px7)+px8*log2(1/px8);//entropy\n", +"disp('bits/message',HX,'H(X) = ');\n", +"r=fs;\n", +"R=r*HX;//information rate\n", +"disp('bits/sec',R,'R = ');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.19: Channel_Matrix_and_joint_probability.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Channel Matrix,joint probability\n", +"//Example 9.19\n", +"//page no 408\n", +"//Find Channel Matrix,joint probability\n", +" \n", +"clc;\n", +"clear;\n", +"px1=0.5;\n", +"px2=0.5;\n", +"py1x1=0.9;\n", +"py2x1=0.1;\n", +"py1x2=0.2;\n", +"py2x2=0.8;\n", +"PYX=[py1x1 py2x1; py1x2 py2x2];\n", +"PX=[px1 px2];\n", +"\n", +"disp(PYX,' i)Channel Matrix [P(Y/X)]=');\n", +"PY=PX*PYX;\n", +"printf('\n\ ii) P(y1)=%.2f and P(y2)=%.2f \n',PY(1),PY(2));\n", +"\n", +"PXd=[px1 0;0 px2];\n", +"PXY=PXd*PYX;\n", +"printf('\n iii)P(x1y2)=%.2f and P(x2y1)=%.2f',PXY(3),PXY(2));\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.1: Information_Content.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Information Content\n", +"//Example 9.1\n", +"//page no 394\n", +"//Find Information Content of Each Symbol\n", +"clc;\n", +"clear;\n", +"px1=1/2;\n", +"px2=1/4;\n", +"px3=1/8;\n", +"px4=1/8;\n", +"//information content of each symbol\n", +"Ix1=log2(1/px1);\n", +"Ix2=log2(1/px2);\n", +"Ix3=log2(1/px3);\n", +"Ix4=log2(1/px4);\n", +"printf('Information Content \n\n \tI(x1) = %d bit \n',Ix1);\n", +"printf(' \tI(x2) = %d bits\n',Ix2);\n", +"printf(' \tI(x3) = %d bits\n',Ix3);\n", +"printf(' \tI(x4) = %d bits\n',Ix4);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.21: probabilities_channel_matrix.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: probabilities channel matrix\n", +"//Example 9.21\n", +"//Find probabilities channel matrix\n", +" \n", +"clc;\n", +"clear;\n", +"p=0.2;\n", +"PX=[0.5 0.5];\n", +"PXY=[1-p p 0;0 p 1-p];\n", +"//P(Y)=[P(X)]*[P(Y|X)]\n", +"PY=PX*PXY\n", +"disp(PY,'[P(Y)]');\n", +"disp(PY(1),'P(y1)=');\n", +"disp(PY(2),'P(y2)=');\n", +"disp(PY(3),'P(y3)=');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.2: Information.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Information\n", +"//Example 9.2\n", +"//page no 394\n", +"//Find amount of Information\n", +"clc;\n", +"clear;\n", +"pxi=1/4;\n", +"Ixi=(log10(1/pxi))/log10(2);\n", +"printf(' \n The amount of Information \n \n\t I(Xi) = %.2d bits',Ixi)" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.35: Capacity_of_Channel.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Capacity of Channel\n", +"//Example 9.35\n", +"//page no 426\n", +"//Find Capacity of Channel\n", +"//Channel is aproximated by the AWGN Channel\n", +"clear;\n", +"clc;\n", +"B=4000;\n", +"S=0.1*10^-3;\n", +"n=2*10^-12;\n", +"N=n*B;\n", +"C=B*log2(1+(S/N));//Capacity of Channel\n", +"printf('\n Capacity of Channel \n\n\t C=%.3f(10^3) b/s',C/1000);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.36_ii: Channel_Capacity.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Channel Capacity \n", +"//Example 9.36ii\n", +"//page no 427\n", +"//Find Capacity of Channel\n", +"//assume that succeissive samples are statistically independent\n", +"clear;\n", +"clc;\n", +"B=10*10^3;\n", +"SN=20;\n", +"SNR=10^(SN/10)\n", +"C=B*log2(1+(SNR));\n", +"disp('kb/s',C/1000,'C =')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.36_iii: SNR.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: SNR\n", +"//Example 9.36iii\n", +"//page no 427\n", +"//Find SNR\n", +"//assume that succeissive samples are statistically independent\n", +"clear;\n", +"clc;\n", +"C=8*10^4;\n", +"B=10^4;\n", +"SN=2^(C/B)-1;\n", +"SNR=10*log10(SN);//SNR\n", +"disp('dB',SNR,'SNR =');//required SNR is greater that 24.064" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.36_i: information_rate.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: information rate\n", +"//Example 9.36i\n", +"//page no 427\n", +"//Find information rate\n", +"//assume that succeissive samples are statistically independent\n", +"clear;\n", +"clc;\n", +"fm=4000;\n", +"fs=2*fm;\n", +"n=1.25;\n", +"r=fs*n;\n", +"pxi=1/256;\n", +"HX=-log2(pxi);\n", +"R=r*HX;\n", +"printf('Information Rate \n\n \t R= %d kb/s',R/1000)" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.36_iv: Bandwidth.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Bandwidth\n", +"//Example 9.36ii\n", +"//page no 427\n", +"//Find Required bandwidth \n", +"//assume that succeissive samples are statistically independent\n", +"clear;\n", +"clc;\n", +"SN=20;\n", +"SNR=10^(SN/10);\n", +"C=8*10^4;\n", +"B=C/(log2(1+SNR));//Bandwidth\n", +"disp('kHz',B/1000,'Bandwidth B = ');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.37: efficiency_and_redundancy.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: efficiency,redundancy\n", +"//Example 9.37\n", +"//page no 430\n", +"//Find code efficiency,redundancy\n", +"clear;\n", +"clc;\n", +"px1=0.9;\n", +"px2=0.1;\n", +"n1=1;\n", +"n2=1;\n", +"L=px1*n1+px2*n2;// code leght\n", +"HX=px1*log2(1/px1)+px2*log2(1/px2);\n", +"n=(HX/L);// code efficiency\n", +"\n", +"printf('\n\tcode efficiency = %.2f ',n*100);\n", +"disp(' %');\n", +"\n", +"r=(1-n);//code reduncy\n", +"printf('\n\n\tcode redundancy = %.2f ',r*100);\n", +"disp(' %');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.38: Efficiency_and_redundancy.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: efficiency,redundancy\n", +"//Example 9.38\n", +"//page no 431\n", +"//Find code efficiency,redundancy\n", +"clear;\n", +"clc;\n", +"pa1=0.81;\n", +"pa2=0.09;\n", +"pa3=0.09;\n", +"pa4=0.01;\n", +"n1=1;\n", +"n2=2;\n", +"n3=3;\n", +"n4=3;\n", +"\n", +"L=pa1*n1+pa2*n2+pa3*n3+pa4*n4;\n", +"\n", +"HX2=pa1*log2(1/pa1)+pa2*log2(1/pa2)+pa3*log2(1/pa3)+pa4*log2(1/pa4);\n", +"n=HX2/L;\n", +"\n", +"printf('\n\tcode efficiency = %.2f ',n*100);\n", +"disp(' %');\n", +"\n", +"r=(1-n);//code reduncy\n", +"printf('\n\n\tcode redundancy = %.1f ',r*100);\n", +"disp(' %');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.3: Amount_of_Information.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Amount of Information\n", +"//Example 9.3\n", +"//page no 395\n", +"//Find Amount og Information\n", +"clc;\n", +"clear;\n", +"px1=1/2;\n", +"px2=1/2;\n", +"Ix1=log2(1/px1);//entropy\n", +"Ix2=log2(1/px2);\n", +"\n", +"printf(' \n The amount of Information \n \n\t I(X1) = %.2d bit\n',Ix1);\n", +"printf(' \n The amount of Information \n \n\t I(X2) = %.2d bit',Ix2);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.44: Efficiency.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: efficiency\n", +"//Example 9.44\n", +"//page no 436\n", +"//Find efficiency of the code\n", +"clear;\n", +"clc;\n", +"\n", +"px1=1/2;\n", +"px2=1/4;\n", +"px3=1/8;\n", +"px4=1/8;\n", +"n1=1\n", +"n2=2;\n", +"n3=3;\n", +"n4=3;\n", +"\n", +"//information content of each symbol\n", +"Ix1=-log2(px1);\n", +"Ix2=-log2(px2);\n", +"Ix3=-log2(px3);\n", +"Ix4=-log2(px4);\n", +"\n", +"HX=px1*log2(1/px1)+px2*log2(1/px2)+px3*log2(1/px3)+px4*log2(1/px4);\n", +"L=px1*n1+px2*n2+px3*n3+px4*n4;\n", +"\n", +"n=HX/L;\n", +"\n", +"printf('\n\tcode efficiency = %.2f ',n*100);\n", +"disp(' %');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.4: Amount_of_Information.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Amount of Information \n", +"//Example 9.4\n", +"//page no 395\n", +"//Find Amount of Information \n", +"clc;\n", +"clear;\n", +"px1=1/4;\n", +"px2=3/4;\n", +"Ix1=log2(1/px1);\n", +"Ix2=log2(1/px2);\n", +"\n", +"printf(' \n The amount of Information \n \n\t I(X1) = %.2d bits\n',Ix1);\n", +"printf(' \n \t I(X2) = %.3f bits',Ix2);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.50: Entropy_and_information_rate.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: entropy ,information rate\n", +"//Example 9.50\n", +"//Pge no 441\n", +"//Find entropy ,information rate\n", +"//If there are 16 outcomes per second\n", +"clear;\n", +"clc;\n", +"\n", +"P1=1/2;\n", +"P2=1/4;\n", +"P3=1/8\n", +"P4=1/16;\n", +"P5=1/32;\n", +"P6=1/32;\n", +" r=16;//message rate\n", +"H=P1*log2(1/P1)+P2*log2(1/P2)+P3*log2(1/P3)+P4*log2(1/P4)+P5*log2(1/P5)+P6*log2(1/P6); //Entropy of system\n", +"printf('\n \t i)Entropy of system \n\n \t H=%.4f bits/message\n',H);\n", +"R=H*r; //R=Entropy*message rate\n", +"printf('\n \t ii)Information rate\n \n\t R = %d bits/sec',R);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.51: Entropy.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Entropy\n", +"//Example 9.51\n", +"//Pge no 443\n", +"//Calculate H(X) ,H(Y)\n", +"clear;\n", +"clc;\n", +"\n", +"px1=0.3;\n", +"px2=0.4;\n", +"px3=0.3;\n", +"\n", +"HX=px1*log2(1/px1)+px2*log2(1/px2)+px3*log2(1/px3);//Entropy of X\n", +"printf('\n \t i)Entropy of X \n\n \t H(X)=%.3f bits/symbol\n',HX);\n", +"\n", +"PYX=[0.8 0.2 0;0 1 0;0 0.3 0.7]\n", +"PX=[px1 px2 px3]\n", +"PXY=PX*PYX;\n", +"py1=PXY(1,1);\n", +"py2=PXY(1,2);\n", +"py3=PXY(1,3);\n", +"\n", +"HY=py1*log2(1/py1)+py2*log2(1/py2)+py3*log2(1/py3);//Entropy of Y\n", +"printf('\n \t ii)Entropy of Y \n\n \t H(Y)=%.2f bits/symbol\n',HY);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.52: Entropy.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Entropy\n", +"//Example 9.52\n", +"//Pge no 442\n", +"//Find entropy of source ,entropy of second order extension\n", +"\n", +"clear;\n", +"clc;\n", +"\n", +"P1=0.7;\n", +"P2=0.15;\n", +"P3=0.15;\n", +"\n", +"HX=P1*log2(1/P1)+P2*log2(1/P2)+P3*log2(1/P3)// Entropy of source\n", +"printf('\n \t i)Entropy of system \n\n \t H(X)=%.4f bits/symbol\n',HX);\n", +"//H(X^n)=n*H(X)\n", +"n=2;//for second order\n", +"HX2=n*HX;\n", +"printf('\n \t ii)Entropy of second order system extension of source can be');\n", +"printf(' \n\n \t H(X^2)=%.4f bits/symbol\n',HX);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.54: Entropy.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Entropy\n", +"//Example 9.54\n", +"//Pge no 443\n", +"//Find entropy of source \n", +"clear;\n", +"clc;\n", +"S0=1/3;\n", +"S1=1/6;\n", +"S2=1/4;\n", +"S3=1/4\n", +"\n", +"HX=S0*log2(1/S0)+S1*log2(1/S1)+S2*log2(1/S2)+S3*log2(1/S3);// EntroSy of source\n", +"\n", +"printf('\n \t i)Entropy of system \n\n \t H(X)=%.4f bits/symbol\n',HX);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.56: Information_capacity.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Information capacity\n", +"//Example 9.56\n", +"//page no 444\n", +"//Find Information capacity of telephone\n", +"clear;\n", +"clc;\n", +"B=3.4*10^3;\n", +"SNR=30\n", +"SN=10^(SNR/10);\n", +"C=B*log2(1+SN)//Information capacity\n", +"printf('Information capacity of telephone is \n\n \tC = %.2f kbps',C/1000);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.9: Entropy.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Entropy\n", +"//Example 9.9\n", +"//page no 398\n", +"//Find Entropy,Amount of information\n", +"clc;\n", +"clear;\n", +"px1=0.4;\n", +"px2=0.3;\n", +"px3=0.2;\n", +"px4=0.1;\n", +"HX=-px1*log2(px1)-px2*log2(px2)-px3*log2(px3)-px4*log2(px4);\n", +"printf(' \n Entropy \n \n\t i) H(X) = %.2f bits/symbol,\n',HX);\n", +"Px1x2x1x3=px1*px2*px1*px3;\n", +"Ix1x2x1x3=-log2(Px1x2x1x3);\n", +"\n", +"printf(' \n Amount of information \n \n\t ii) I(x1x2x1x3) = %.2f bits/symbol,\n',Ix1x2x1x3);\n", +"Px4x3x3x2=px4*px3*px3*px2;\n", +"Ix4x3x3x2=-log2(Px4x3x3x2);\n", +"\n", +"printf(' \n \t \n \t I(x4x3x3x2) = %.2f bits/symbol.\n',Ix4x3x3x2);" + ] + } +], +"metadata": { + "kernelspec": { + "display_name": "Scilab", + "language": "scilab", + "name": "scilab" + }, + "language_info": { + "file_extension": ".sce", + "help_links": [ + { + "text": "MetaKernel Magics", + "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md" + } + ], + "mimetype": "text/x-octave", + "name": "scilab", + "version": "0.7.1" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} |