summaryrefslogtreecommitdiff
path: root/1895/CH11/EX11.28/EXAMPLE11_28.SCE
diff options
context:
space:
mode:
Diffstat (limited to '1895/CH11/EX11.28/EXAMPLE11_28.SCE')
-rwxr-xr-x1895/CH11/EX11.28/EXAMPLE11_28.SCE32
1 files changed, 32 insertions, 0 deletions
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);