function p = erlangb(A,N,k)
%ERLANGB Calculates probabilities using the Erlang-B formula
%Call p = erlangb(A,N,k)
%Where A = offered traffic in Erlang
%      N = number of serving trunks 
%      k = numbers in the range 0,...,N at which p is calculated
%Returns
%      p = vector of Erlang-B probabilities specified by k
%
if nargin < 3,
   k =[0:N];
endif;
a = exp((0:N)*log(A)-[0,cumsum(log(1:N))]); 
d = sum(a');
p = a(k+1)/d;
