summaryrefslogtreecommitdiff
path: root/1895/CH11/EX11.54/EXAMPLE11_54.SCE
blob: 9dfaf057b62eda29874bd0be1e980a633ae6be73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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)