Professional Documents
Culture Documents
Samalkha
Computer Science & Engineering Department
Affiliated to
INDEX
Sr. PRACTICAL STATEMENT DATE SIGNATURE
1. Introduction of MATLAB.
Self Information
Result:
Practical no – 3
Aim :- Determination of entropy of a given source as well as source rate.
Software Required :- MATLAB 2015 a
Result:
hx = 2.1219
entropy rate
p=[0.2 0.4 0.1 0.2 0.1];
t=[0.0001 0.0002 0.0003 0.0004 0.0005];
hx=0;
tx=0;
for i=1:5
hx=hx+(-p(i)*log2(p(i)));
tx=tx+p(i)*t(i);
rx=hx/tx;
end
hx
tx
rx
Result:
hx = 2.1219
tx = 2.6000e-04
rx = 8.1613e+03
Practical no – 4
Result:
hy = 1.5526
hx = 1.5813
hxy = 2.7566
Practical no – 6
Result:
k = -0.4690
hy =0.8813
c = 0.5310
I = 0.4123
E = 77.6444
R = 22.3556
Practical no - 8
Shannon code
x=[0.25 0.12 0.13 0.1 0.08 0.07 0.06 0.05 0.04 0.035
0.025 0.02 0.01 0.01];
m=[];
for i=1:14
b=-log2(x(i));
l=fix(b);
if l==b
m(i)=l;
else
l=l+1;
m(i)=l;
end
end
lc=0;
for i=1:14
lc=lc+m(i)*x(i);
end
lc
hx=0;
for i=1:14
hx=hx+(-x(i)*log2(x(i)));
end
hx
eff=hx/lc
Result:
lc= 3.7050
hx = 3.3354
eff = 0.9003
Practical no – 9
Huffman Code:
x=[1 2 3 4 5];
p=[0.1 0.2 0.4 0.1 0.2];
dict=huffmandict(x,p)
dict(:,:);
hcode=huffmanenco(x,dict);
for i=1:5
samplecode=dict(i,2);
end
Result:
dict=
[1][1x4 double]