Demo entry 6762922

hw5-7h

   

Submitted by anonymous on Oct 17, 2018 at 21:05
Language: Matlab. Code size: 392 Bytes.

clear; close all;
J=16;
p=1/J;
N=10^5;
lambda=0.9*p*(1-p)^(J-1);
x = aloha_simulation(J,p,lambda,N);
Q1=max(x(1,:));
freq=zeros(1,Q1+1);
for i=0:Q1
    freq(1,i+1)=sum(x(1,:)==i);
end
rho=lambda/(p*(1-p)^(J-1));
A=[freq/N;(1-rho)*(rho.^(0:Q1))];
A=A';

figure;
bar(0:Q1,A,0.5);
xlabel('# of packets in queue');
ylabel('calculated probability');grid on;
axis([-1 Q1 0 0.4]);

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).