MATLAB CODE
close all
clear all
lambda=0:0.0001:0.0065; % mean arrival rate (calls per second)
d=200; % mean duration (seconds per call)
A = lambda.*d; % traffic intensity in Erlangs
N = 1;
[ B, Bd ] =erlangb( N, A )
% Bd=erlangb(N, A)
% B = erlangb(N, A); % n channels/servers
ii=find(B<0.1);
jj=find(Bd<0.1)
plot(A(ii), B(ii), 'b')
hold on
plot(A(jj), Bd(jj), 'R')
hold on
N = 2;
[ B, Bd ] =erlangb( N, A )
ii=find(B<0.1);
jj=find(Bd<0.1)
plot(A(ii), B(ii), 'b')
hold on
plot(A(jj), Bd(jj), 'R')
hold on
N = 3;
[ B, Bd ] =erlangb( N, A )
plot(A, B, 'b')
hold on
plot(A, Bd, 'R')
hold on
N = 4;
[ B, Bd ] =erlangb( N, A )
plot(A, B, 'b')
hold on;
plot(A, Bd, 'R')
hold on
xlabel('Traffic Intensity (Erlangs)');
ylabel('Blocking Probability');
title('Erlang B/C formula,suleiman saleh said 2820170009');
plot(A, 0.02, ':k') % 2% line
grid on;
end
function [ B, Bd ] =erlangb( N, A )
% Define the erlang function
% function B = erlangb(N, A)
if (length(N)~=1) | (fix(N) ~= N) | (N < 0)
error('N must be a scalar positive integer');
end
% TODO: test that elements of A are real and positive here?
esum = zeros(size(A))
for ii=0:N
esum = esum + A .^ ii ./ factorial(ii);
end
B = A .^ N ./ (factorial(N) .* esum)
for jj=0:N-1
esum1 = esum + A .^ ii ./ factorial(ii);
end
Bd= A .^ N./((A .^ N)+factorial(N).*(1-A./N).*esum1)
end
OBSERVATION:
Red line: Erlang C
Blue Line: Erlang B
The red line represent Erlang C while the blue line represent the Erlang B, as we expected that the Erlang C which
represent the probability of the delay call ( call being hold for a while before dropped ) to be lagging behind the Erlang
B which represent the probability of a call to be blocked immediately if no free channel is available
Erlang C lagg behind Erlang B