Skip to content

Erlang A in Python for Call Abandonment ​

Erlang A estimates how many agents a contact center needs when callers may hang up before service. The M/M/c+M model gives each waiting caller an exponentially distributed patience time with mean patience. In the Python example, 100 calls in 30 minutes need 13 productive agents, or 19 scheduled agents at 30% shrinkage.

How it is computed ​

pyworkforce computes every Erlang A metric exactly from the stationary distribution of the underlying birth-death Markov chain. The birth rate λ is the arrival rate. With n callers in the system, the death rate is

min(n,c)μ+max(n−c,0)θ

Here c is the number of servers, μ=1/AHT is the service rate per busy server, and θ=1/patience is the abandonment rate per waiting caller. The first term counts service completions. The second counts callers leaving the queue. That departure rate rises as the queue grows, so the system is stable at any finite arrival rate with a positive abandonment rate.

Sanity check

As patience grows, the Erlang A metrics converge to the Erlang C results when the equivalent Erlang C queue is stable. pyworkforce's test suite verifies this, and also checks the analytic metrics against a Monte Carlo simulation.

The queue system ​

Erlang A callers wait for an agent when all agents are busy. They can abandon while waiting or leave after service.

The dashed branch shows callers who leave while waiting. Once service begins, they continue through to completion.

Basic usage ​

python
from pyworkforce.queuing import ErlangA

erlang = ErlangA(transactions=100, aht=3, asa=20 / 60,
                 interval=30, patience=5, shrinkage=0.3)

print(erlang.required_positions(service_level=0.8,
                                max_occupancy=0.85,
                                max_abandonment=0.05))
text
{'raw_positions': 13,
 'positions': 19,
 'service_level': 0.8581777000307627,
 'occupancy': 0.7500282279741758,
 'abandonment_probability': 0.02496330363357157,
 'waiting_probability': 0.22579708404737525,
 'average_speed_of_answer': 0.12481651816785785}

required_positions finds the smallest number of positions that meets all of the targets you set: the service level, the maximum occupancy and the maximum abandonment probability.

Per-position metrics ​

For a fixed number of positions you can read each metric directly:

python
erlang.waiting_probability(positions=14)       # P(delayed)
erlang.abandonment_probability(positions=14)   # P(customer abandons)
erlang.achieved_occupancy(positions=14)        # server utilization
erlang.average_speed_of_answer(positions=14)   # expected wait (minutes)
erlang.average_queue_length(positions=14)      # expected number waiting
erlang.service_level(positions=14)             # answered within asa

You can override the answer-time target per call:

python
erlang.service_level(positions=14, asa=30 / 60)

Parameters ​

ParameterMeaning
transactionsArrivals in the interval
ahtAverage handle time
asaTarget answer time (default service-level threshold)
intervalInterval length
patienceMean time a customer waits before abandoning
shrinkageFraction of unavailable time, in [0, 1)

asa, aht, interval and patience must share the same time unit.

Erlang C vs Erlang A ​

Erlang CErlang A
Customers abandon?NoYes
Tends toover-staffrealistic staffing
Extra parameterNonepatience
Extra outputsNoneabandonment probability, queue length

Use Erlang A when abandonment is material to your operation, and Erlang C as a conservative baseline.

Common pitfalls ​

  • patience is a mean patience time, not a hard maximum waiting time.
  • Keep asa, aht, interval and patience in the same unit.
  • Set a max_abandonment target when abandonment is a business constraint, not just a modeling assumption.
  • Compare against Erlang C when you need a conservative staffing estimate.

See the Erlang A API reference for all input and output fields.

Released under the MIT License.