Sie sind auf Seite 1von 16

Probability density function of various Distribution

PROGRAM:
clc;
clear all;
x=0:15;
disp('Poission Distribution');
lambda=input('Enter the value of lambda:');
a=poisspdf(x,lambda);
subplot(5,2,1),plot(x,a);
title('Poission distribution');

x=0:20;
disp('Uniform continuous distribution');
n=input('Enter the value of n:');
m=input('Enter the value of m:');
b=unifpdf(x,n,m);
subplot(5,2,2),plot(x,b);
title('Unifrom continuous distribution');

x=1:50;
disp('Uniform discrete distribution');
p1=input('Enter the value of p1:');
c=unidpdf(x,p1);
subplot(5,2,3),stem(c(1:50));
title('unifrom discrete distribution');

x=0:20;
disp('Binominal distruibution');
p=input('Enter the value of p:');
q=input('Enter the value of q:');
d=binopdf(x,p,q);
subplot(5,2,4),plot(x,d);
title('Binominal distribution');

x=0:20;
disp('Negative binominal distribution');
r=input('Enter the value of r:');
s=input('Enter the value of s:');
e=nbinpdf(x,r,s);
subplot(5,2,5),plot(x,e);
title('Negative binominal distribution');

x=0:20;
disp('expontentional distribution');
t=input('Enter the value of t:');
f=exppdf(x,t);
subplot(5,2,6),plot(x,f);
title('Expontential distribution');

x=-30:30;
disp('Gaussion distribution');
u=input('Enter the value of u:');
v=input('Enter the value of v:');
g=normpdf(x,u,v);
subplot(5,2,7),plot(x,g);
title('Normal distribution');

x=1:20;
disp('Geometeric distribution');
u1=input('Enter the value of u1:');
h=geopdf(x,u1);
subplot(5,2,8),bar(h(1:20));
title('Geometeric distribution');

x=0:40;
disp('Gamma distribution');
u2=input('Enter the value of u2:');
v1=input('Enter the value of v1:');
i=gampdf(x,u2,v1);
subplot(5,2,9),plot(x,i);
title('Gamma distribution');

x=0:50;
disp('Rayliegh Distribution');
z=input('Enter the value of z:');
j=raylpdf(x,z);
subplot(5,2,10),plot(x,j);
title('Ray distribution');
SAMPLE INPUT AND OUTPUT:

POISSON DISTRIBUTION:
Enter the value of lamda:

UNIFROM CONTINUOUS DISTRIBUTION


Enter the value of n:
Enter the value of m:

UNIFROM DISCRETE DISTRIBUTION


Enter the value of p1:

BINOMINAL DISTRIBUTION
Enter the value of p:
Enter the value of q:

NEGATIVE BINOMINAL DISTRIBUTION


Enter the value of r:
Enter the value of s:

EXPONTENTIONAL DISTRIBUTION
Enter the value of t:

GAUSSION DISTRIBUTION
Enter the value of u:
Enter the value of v:

GEOMETRIC DISTRIBUTION
Enter the value of u1:

GAMMA DISTRIBUTION
Enter the value of u2:
Enter the value of v1:

RAYLIEGH DISTRIBUTION
Enter the value of z:
GENERATION OF PN SEQUENCES:
PROGRAM
clear all ;
close all;
len=input('Enter the length of the sequence:');
disp('Generation poly example[1 0 0......1]');
poly=input('Enter the poly sequence:');
disp('Generation of poly example[1 0 1 0]');
ini=input('Enter the initial step:');
ff=log2(len+1);

%PN sequence generation

a=zeros(len,ff);
a(1,1:ff)=ini;
for i=1:(len-1)
x=0;
for j=2:(ff+1)
if(poly(1,j)==1)
x=xor(x,a(i,(j-1)));
end;
end;
a((i+1),1:ff)=circshift(a(i,1:ff),[0 1]);
a((i+1),1)=x;
end;

for i=1:len
h(1,i)=a(i,ff);
end;
fprintf('Sequence generation is\n');
disp(h);
%Properties

%balance property

check=0;
one=0;
zero=0;
for i=1:len
if((h(1,i))==0)
zero=zero+1;
else
one=one+1;
end;
end;
disp('Balance property');
disp('no of ones');
disp(one);
disp('no of zeros');
disp(zero);
if((one-zero)==1)
fprintf('Balance property satisfied');
else
fprintf('balance property not satisfied\n\n');
check=1;
end;

%Auto correlation

for i=1:len
y(i,:)=xor(h,circshift(h,[0 i]));
end;
%disp(y);
for i=1:len
one=0;
zero=0;
for j=1:len
if((y(i,j))==0)
zero=zero+1;
else
one=one+1;
end
z(i,1)=(zero-one);
end
end
for i=1:(len-1)
g(i,1)=-1;
end
g(len,1)=len;
disp('Auto correlation property');
disp(z);
if(z==g)
fprintf('Autocorrelation property is satisfied\n\n');
check=3;
else
fprintf('Autocorrelation property is not satisfied\n\n');
check=2;
end

%Run property
runs=((len+1)/2);
u=ff;
r=zeros(1,u);
count=1;
for i=1:len-1
if(h(1,i)==h(1,i+1))
count=count+1;
else
r(1,count)=r(1,count)+1;
count=1;
end;
end;
r(1,count)=r(1,count)+1;
s=zeros(1,u);
for i=1:(u-1)
s(1,i)=runs/(2.^i);
end
s(1,u)=1;
disp('run property');
for i=1:u
fprintf('%d\t\t\t\t%d\n',r(1,i),i);
end
if(r==s)
fprintf('Run property is satisfied\n\n');
check=4;
else
fprintf('Run property is not satisfied\n');
check=2;
end ;
if (check==2)
disp('The givrn sequence is not a PN sequence\n\n');
else
disp('\n\nThe given sequence is a PNsequence ');
end
OUPUT:
Enter the length of the sequence:7
Generation poly example:[1 0 0......1]
Enter the poly sequence:[1 1 0 1]
Generation of poly example[1 0 1 0]
Enter the initial step:[1 0 0]
Sequence generation is
0 0 1 1 1 0 1

Balance property:
no of ones
4

no of zeros
3

Balance property satisfied.


Auto correlation property
-1
-1
-1
-1
-1
-1
7

Autocorrelation property is satisfied

Run property
Runs Runlength
2 1
1 2
1 3
Run property is satisfied

The given sequence is a PNsequence


OUTPUT:
Enter the length of the sequence:15
Generation poly example:[1 0 0......1]
Enter the poly sequence:[1 0 1 1 1]
Generation of poly example[1 0 1 0]
Enter the initial step:[1 0 1 1]
Sequence generation is
1 1 0 1 0 0 1 1 1 0 1 0 0 1 1

BALANCE PROPERTY
no of ones
9

no of zeros
6

balance property not satisfied

AUTOCORRELATION PROPERTY -1
-1
-1
-5
-1
-1
7
7
-1
-1
-5
-1
-1
-1
15

Autocorrelation property is not satisfied

RUN PROPERTY
RUNS RUNLENGTH
4 1
4 2
1 3
0 4
Run property is not satisfied
The given sequence is not a PN sequence
ON OFF TRAFFIC
PROGRAM:
clc;
clear all;
x=1:10;
t=1:100;
on=input('Enter the average on time');
%Users Vs average ON time
ton=zeros(10,100);
for i=1:10
ton(i,:)=poissrnd((on*10),1,100);
end
a=ton';
b=mean(a);
c=b/10;
figure(1);
bar(x,c);
xlabel('Users');
ylabel('Average ON time');
%Timeslot Vs number of users
n=zeros(10,100);
for i=1:10;
for j=1:100;
if(ton(i,j)>=3.5)
n(i,j)=1;
end
end
end
d=sum(n);
figure(2);
bar(t,d);
xlabel('Timeslot');
ylabel('No. of users');
%Time slot Vs Bandwidth
bw=64000*n;
for i=1:10
figure(3);
subplot(5,2,i);
bar(t,bw(i,:),.2);
xlabel('Timeslot');
ylabel('bw allocated');
end

SAMPLE INPUT AND OUTPUT:


Enter the ON averge time:0.5
DATA TRAFFIC
PROGRAM:
clear all;
clc;
use=input('Enter the no. of user:');
ts=input('Enter the no. of time slots:');
on=0.35;
ton=zeros(use,ts);
n=ton;
for i=1:use
for j=1:ts
ton(i,:)=poissrnd((on*10),1,ts);
if(ton(i,j)>=3.5)
n(i,j)=1;
end;
end;
end;
test =randint(use,ts,[1,1000]);
data=n;
for i=1:use
for j=1:ts
if n(i,j)==1
if test(i,j)>=10 & test (i,j)<=980
data (i,j)=64000;
else if test(i,j)>980 & test(i,j)<=980
data(i,j)=128000;
else if test(i,j)>980 & test (i,j)<=990
data(i,j)=256000;
else
data(i,j)=512000;

end;
end;
end;
end;
end;
end;
%Time slot Vs BW
d=sum (data);
figure(1);
bar(d);
xlabel('Time slot');
ylabel('Bandwidth');
%Time slot Vs Error Rate
e=zeros(1,ts);
bm=1540000;
for i=1:ts
if d(i)>bm
e(i)=d(i)-bm
end;
end;
figure(2);
bar(e);
xlabel('Timeslot');
ylabel('Error rate(bps)');
avg=sum(e')/ts;
ber=avg/bm;
buff=0;
disp('Average bit error without buffering:');
disp(ber);
while ber >1e-6
buff=buff+10;
bm=bm+10;
for i=1:ts;
if e(i)>0
e(i)=d(i)-bm;
end;
end;
s=sum(e');
ber=s/(ts*bm);
end;
disp('Bit error rate with buffer:');
disp(ber);
disp('Optimum buffer size:');
disp(buff);

SAMPLE INPUT AND OUTPUT:


Enter the no. of user :80
Enter no. of time slots:130
Average bit error without buffering:0.7448
Bit error rate with buffer:9.881e-007
Optimun buffer size:2427490
VOICE TRAFFIC
PROGRAM
clc;
clear all;
use=input('Enter the no. of users:');
ts=input('Enter the no. of time slot:');
on=0.35;
ton=zeros(use,ts);
n=ton;
for i=1:use
for j=1:ts
ton(i,:)=poissrnd((on*10),1,ts);
if(ton(i,j)>=3.5)
n(i,j)=1;
end
end
end
voice=64000*n;
%Timeslot Vs BW
d=sum(voice);
figure(1);
bar(d);
xlabel('Time slot');
ylabel('Bandwidth(bps)');
%Time slot Vs Error rate
e=zeros(1,ts);
bm=1540000;
for i=1:ts
if d(i)>bm
e(i)=d(i)-bm;
end
end
figure(2);
bar(e);
xlabel('Time slot');
ylabel('Error rate(bps)');
avg=sum(e')/ts;
ber=avg/bm;
buff=0;
disp('Average bit error without buffring:');
disp(ber);
while ber>1e-6
buff=buff+10;
bm=bm+10;
for i=1:ts
if e(i)>0
e(i)=d(i)-bm;
end
end
s=sum(e');
ber=s/(ts*bm);
end
disp('Bit error rat with buffer:');
disp(ber);
disp('Optimum buffer size');
disp(buff);

SAMPLE INPUT AND OUTPUT:

Enter the no. of user :60

Enter no. of time slots:100

Average bit error without buffering:0.1579

Bit error rate with buffer:9.864e-007

Optimun buffer size:891760


VIDEO TRAFFIC
PROGRAM
clear all;
clc;
use=input('Enter the no. of user:');
ts=input('Enter the no. of time slots:');
on=0.35;
ton=zeros(use,ts);
n=ton;
for i=1:use
for j=1:ts
ton(i,:)=poissrnd((on*10),1,ts);
if(ton(i,j)>=3.5)
n(i,j)=1;
end;
end;
end;
test =randint(use,ts,[1,1000]);
data=n;
for i=1:use
for j=1:ts
if n(i,j)==1
if test(i,j)>=10 & test (i,j)<=980
data (i,j)=64000;
else if test(i,j)>980 & test(i,j)<=980
data(i,j)=128000;
else if test(i,j)>980 & test (i,j)<=990
data(i,j)=256000;
else
data(i,j)=512000;

end;
end;
end;
end;
end;
end;
%Time slot Vs BW
d=sum (data);
figure(1);
bar(d);
xlabel('Time slot');
ylabel('Bandwidth');
%Time slot Vs Error Rate
e=zeros(1,ts);
bm=1540000;
for i=1:ts
if d(i)>bm
e(i)=d(i)-bm
end;
end;
figure(2);
bar(e);
xlabel('Timeslot');
ylabel('Error rate(bps)');
avg=sum(e')/ts;
ber=avg/bm;
buff=0;
disp('Average bit error without buffering:');
disp(ber);
while ber >1e-6
buff=buff+10;
bm=bm+10;
for i=1:ts;
if e(i)>0
e(i)=d(i)-bm;
end;
end;
s=sum(e');
ber=s/(ts*bm);
end;
disp('Bit error rate with buffer:');
disp(ber);
disp('Optimum buffer size:');
disp(buff);

SAMPLE INPUT AND OUTPUT:

Enter the no. of user :85

Enter no. of time slots:130

Average bit error without buffering:0.8596

Bit error rate with buffer:9.9219e-007

Optimun buffer size:2491480

Das könnte Ihnen auch gefallen