Code covered by the BSD License  

Highlights from
entropy, Reduenduncy,information rate

entropy, Reduenduncy,information rate

by

 

calculate the Entropy,Reduenduncy and information rate in two cases (memory or memoryless)

Y_S.m
% this code is calculating the Entropy,Max_Entropy,Reduenduncy,information
% rate, for memory or  memoryless system 
% By Yaman Salem 

w=input('Enter the number of symbol:  ');
br=input('Enter the baud rate{ex; 1024}:  ');
q=input('The system is memory(enter 0) or memoryless (enter 1) ??? 0/1  ');
if q == 1
i=0;
sum=0;
for r=i:w-1;    
    display( sprintf('p[%d]',i));
   t= input('the probapility of symbol NO.');
   i=i+1;
 sum=sum+t.*log2(1/t);
end;
fprintf('the entropy is ');
fprintf('%d\n',sum);
Hmax=log2(w);
fprintf('the max entropy is ');
fprintf('%d\n',Hmax);
R=Hmax-sum;
fprintf('the Reduenduncy is ');
fprintf('%d\n',R);
fprintf('the information rate ');
RI=br*sum;
fprintf('%d\n',RI);
 
else 
    sum=0;
   b=zeros(w,1);
   for i=1:w;    
   display( sprintf('p[%d]',i));
   b(i,1)= input(' Enter the probapility of symbol NO.');
   end
    a=zeros(w,w);
   for i=1:w;
       for j=1:w;
   display( sprintf('p[ %d|%d ]',j,i));
   a(j,i)= input('Enter the probapility of symbol NO.');
   t=(1./a(j,i));
  sum=sum+b(i,1).*a(j,i).*log2(t);
  
       end
   end
   fprintf('the entropy is  ');
fprintf('%d\n',sum);
Hmax=log2(w);
fprintf('the max entropy is  ');
fprintf('%d\n',Hmax);
R=Hmax-sum;
fprintf('the Reduenduncy is  ');
fprintf('%d\n',R);
fprintf('the information rate  ');
RI=br*sum;
fprintf('%d\n',RI);
end

Contact us