…
…
Model hourly call counts with the Poisson distribution and call durations with the normal distribution, build an hour-by-hour staffing plan, and test it against a flat plan by simulation.
The university's Student Help Line gets a lot of calls during the registration period (August 31 to October 23, 2026). Until now every hour had the same number of agents on the schedule. At lunchtime the line jammed, while in the morning and evening agents sat idle. The line manager wants to use data to decide how many agents each hour needs next term.
Data:
| File | Columns | Description |
|---|---|---|
calls.csv | date, hour, calls | Number of incoming calls for each hour from 09:00 to 18:59 on 40 working days (hour = 9 means 09:00-09:59) |
call_durations.csv | call_id, duration_min | Duration (in minutes) of 500 randomly chosen calls |
Simplification: Computing the waiting time directly needs queueing theory. In this project we use a simpler rule. An agent can handle 60 / average call duration calls per hour, and we assume 85% occupancy to leave room for breaks and paperwork. An hour counts as covered if the number of calls in that hour does not exceed the total capacity of that hour. The goal: each hour should be covered with a probability of at least 95%.
Lessons used: probability and simulation (23), discrete distributions: Poisson (25), normal distribution (26).
What you'll do
Required topics
calls.csvDownload file
Reading file…
call_durations.csvDownload file
Reading file…
Code cells are for members
You can read the steps. Sign up free to run the code, complete the steps and save your progress.
For each hour, compute the average number of calls over the 40 days. In the next steps, these averages will be the Poisson parameter λ (lambda) of each hour. Also look at the average of the daily total.
This step's code cell is for members.Sign up free
The number of events that arrive independently of each other follows a Poisson distribution, and in a Poisson distribution the variance equals the mean. For each hour, compute the mean and the variance and look at their ratio. If the ratios are close to 1, the Poisson model is reasonable.
40 days is a small sample, so ratios between 0.7 and 1.3 are not surprising. What matters is that the ratios are not systematically far from 1.
This step's code cell is for members.Sign up free
The busiest hour is 11:00. Using the λ of this hour, compute the probability under the Poisson model of getting at least 50 calls, and compare it with how often this actually happened in the 40 days. Also find the number of calls that is not exceeded in 95% of the hours (ppf): this number will be the basis of the staffing plan.
Code cells are for members
You can read the steps. Sign up free to run the code, complete the steps and save your progress.
Reminder: "at least 50" = "more than 49", so use sf(49).
This step's code cell is for members.Sign up free
The capacity of an agent depends on the average call duration. Can we summarize the durations with a normal model? Check the 68-95 rule and the Q-Q fit correlation (stats.probplot). If the model fits, use it to compute the share of calls longer than 10 minutes and the duration below which 90% of the calls fall, and compare the first with the real share.
This step's code cell is for members.Sign up free
The hourly capacity of one agent is 60 / average duration × 0.85. For each hour, find the 95th percentile of calls under the Poisson model, divide it by the capacity, and round up. The result is the number of agents to schedule for that hour.
stats.poisson.ppf returns a NumPy array. To match the result with the hours, wrap it in pd.Series(..., index=lam.index).
This step's code cell is for members.Sign up free
The plan was built for each hour separately, against the 95% goal. But how does a whole day go? Simulate 10,000 days with a generator seeded with 42: for each hour, draw a Poisson number of calls whose λ is the average of that hour, and compare the calls with the capacity.
Compare the plan with the old method, which schedules a flat number of agents for the whole day. For the flat plan, spread the total agent-hours evenly over the 10 hours and round up: 55 / 10 = 5.5, so 6 agents. The flat plan therefore uses 60 agent-hours, 5 more than the plan. Which one covers better with fewer agent-hours?
This step's code cell is for members.Sign up free