# Compute Loss Probabilities for a Queue

 In[2]:= XPlot[Evaluate@Table[ErlangB[c, a], {c, {1, 15, 30, 45}}], {a, 0.1, 80}, Filling -> Axis, ImageSize -> 300, AxesLabel -> {"a", "prob"}, PlotLegends -> LineLegend[ Table[StringJoin["c = ", ToString[c]], {c, {1, 15, 30, 45}}]]]
 In[3]:= XDynamicModule[{NumberOfCallLines, bht = 21, pr = 0.02}, Grid[{{"", Style["Erlang B Calculator", Bold], ""}, {"Traffic", "Blocking", "Lines"}, {InputField[Dynamic[bht], Number, FieldSize -> 7], InputField[Dynamic[pr], Number, FieldSize -> 7], Style[Dynamic@NumberOfCallLines[bht, pr], {Bold, Blue}]}, {Button[ "Calculate"], SpanFromLeft}}, Alignment -> {Left, Center}, BaseStyle -> {FontFamily -> "Helevetica"}, Spacings -> {3.5, 0.5}, Frame -> True, FrameStyle -> Thick, Background -> Lighter[Yellow, 0.85]], Initialization :> (NumberOfCallLines[a_, p_] /; Positive[a] && Positive[p] && 0 < p < 1 := Block[{n, n1, res}, res = Catch[Do[n1 = n; res = Quiet[ErlangB[n1, a]]; If[res <= p, Throw[n1]], {n, 10^6}]; Throw[\$Failed]]; res /; FreeQ[res, \$Failed]]; NumberOfCallLines[__] := "Failed"), SaveDefinitions -> True]

#### The Erlang B formula computes the probability that a customer is lost from an M/M/c/c queue because all the servers are busy. For example, if there are 30 call lines and the traffic is 25 Erlangs, then the blocking or loss probability is approximately 0.05.

 In[1]:= XErlangB[30, 25.]
 Out[1]=

#### Study the variation of the loss probability for different numbers of lines.

 Out[2]=

#### Calculate the number of lines required, given the traffic and blocking probability.

 Out[3]=