/ Published in: MatLab
PSEUDO BAYESIAN STABILIZATION ALGORITHM IN MATLAB, ESTIMATION OF BACKLOGGED NODES
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
%Student: Santiago Pagola %LiU-ID & Personal Number: 930302-T092, sanpa993 %clear all variables from workspace, close all figures and clear everything %in command line %IMPORTANT NOTE: AN EXTERNAL FUNCTION WAS CREATED IN ORDER TO WRAP THE SUMS %OF THE VECTORS: a = sumk(vector,k). It will be described in the report, %but basically sums the first k elements of an array called 'vector'. m = 100; %100 nodes on no-buffering assumption t = 1000; %Time: 1000 slots of time slots = 1:t; %Slots array n = 0; %Initially, all nodes are unbacklogged %lambda = 1/exp(1); %Overal arrival rate will be set to 1/exp(1) (max. stable throughput) n_estimated = 0; %Estimated backlog initialization. This will be updated during runtime q_r = 0; %Value of q_r is now stabilized by this algorithm packets_leaving = 1:t; %Array which will count #packets leaving the system packets_arriving = 1:t; %Array which will count #packets entering the system v = 1; %Auxiliary variable %main loop for lambda2 = 0.05:0.05:0.35 qa = 1-exp(-lambda2/m); %qa is the probability that each unbacklogged node has to transmit in the next slot %Estimation of q_r starting from the estimated backlog if n_estimated >= 0 && n_estimated < 1 q_r = 1; else q_r = 1/n_estimated; end %Now we are going to create an array with the Poisson pmf's taking into %account the number of transmitting nodes end if 0 <= a && a <= Pr(1) n; elseif sumk(Pr,1) < a && a <= sumk(Pr,2) n = n+1; elseif sumk(Pr,2) < a && a <= sumk(Pr,3) n = n+2; elseif sumk(Pr,3) < a && a <= sumk(Pr,4) n = n+3; elseif sumk(Pr,4) < a && a <= sumk(Pr,5) n = n+4; elseif sumk(Pr,5) < a && a <= sumk(Pr,6) n = n+5; elseif sumk(Pr,6) < a && a <= sumk(Pr,7) n = n+6; elseif sumk(Pr,7) < a && a <= sumk(Pr,8) n = n+7; elseif sumk(Pr,8) < a && a <= sumk(Pr,9) n = n+8; elseif sumk(Pr,9) < a && a <= sumk(Pr,10) n = n+9; elseif sumk(Pr,10) < a && a <= 1 n = n+10; end %Now we are going to create an array with the Qr's (%Probabilities that up to 10 backlogged nodes %retransmit (up to 10 new arrivals)) end if 0 <= n && n < m %Check if the backlog is less than m = 100 n = n-1; x = 2; x = 3; x = 4; x = 5; x = 6; x = 7; x = 8; x = 9; x = 10; end %estimation of n for FEEDBACK e end end end nelements = hist(backlog_array,m); %In each bin, it counts how many times element i was seen ("numerical plot of the hist function") D(v) = N/lambda2; v = v + 1; end hold on hold on grid on %Question 8 lambda2array = [0.05 0.1 0.15 0.2 0.25 0.3 0.35]; hold on