0% found this document useful (0 votes)
66 views1 page

Function File: 'N Must Be A Scalar Positive Integer'

This document contains code to define an Erlang B function and demonstrate its use. The erlangb function calculates blocking probability given traffic intensity and number of channels. The main file generates blocking probabilities for 1-4 channels over a range of traffic intensities and plots the results on a graph with legend and axis labels.

Uploaded by

M. H. Kabir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views1 page

Function File: 'N Must Be A Scalar Positive Integer'

This document contains code to define an Erlang B function and demonstrate its use. The erlangb function calculates blocking probability given traffic intensity and number of channels. The main file generates blocking probabilities for 1-4 channels over a range of traffic intensities and plots the results on a graph with legend and axis labels.

Uploaded by

M. H. Kabir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Function File

% 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);

Main File:
% ex1.m example for erlangb function
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 = erlangb(n, a); % n channels/servers
ii=find(b<0.1);
plot(a(ii), b(ii), 'b')
hold on
n = 2;
b = erlangb(n, a); % n channels/servers
ii=find(b<0.1);
plot(a(ii), b(ii), 'g')
n = 3;
b = erlangb(n, a); % n channels/servers
plot(a, b, 'r')
n = 4;
b = erlangb(n, a); % n channels/servers
plot(a, b, 'k')
legend('1', '2', '3', '4 channels', 0)
xlabel('Traffic Intensity (Erlangs)');
ylabel('Blocking Probability');
title('Erlang B formula');
plot(a, 0.02, ':k') % 2% line

You might also like