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
Here
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
The dashed branch shows callers who leave while waiting. Once service begins, they continue through to completion.
Basic usage
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)){'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:
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 asaYou can override the answer-time target per call:
erlang.service_level(positions=14, asa=30 / 60)Parameters
| Parameter | Meaning |
|---|---|
transactions | Arrivals in the interval |
aht | Average handle time |
asa | Target answer time (default service-level threshold) |
interval | Interval length |
patience | Mean time a customer waits before abandoning |
shrinkage | Fraction of unavailable time, in [0, 1) |
asa, aht, interval and patience must share the same time unit.
Erlang C vs Erlang A
| Erlang C | Erlang A | |
|---|---|---|
| Customers abandon? | No | Yes |
| Tends to | over-staff | realistic staffing |
| Extra parameter | None | patience |
| Extra outputs | None | abandonment probability, queue length |
Use Erlang A when abandonment is material to your operation, and Erlang C as a conservative baseline.
Common pitfalls
patienceis a mean patience time, not a hard maximum waiting time.- Keep
asa,aht,intervalandpatiencein the same unit. - Set a
max_abandonmenttarget 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.