A help-desk simulator needs realistic times at which customers arrive. The gap , in minutes, between one arrival and the next is a continuous random variable with CDF
where (mean_gap) is the average gap in minutes.
Two tools you will need:
math.exp(a).math.log(c).The simulator's random-number generator can only produce uniform draws: numbers between 0 and 1, with every value equally likely. To turn a draw into a gap, it reads the CDF in reverse. The gap for draw is the value at which the CDF reaches :
This works because climbs from 0 towards 1 and never goes back down, so each picks out exactly one . Where climbs steeply (gaps that are likely), a wide band of values all land on a short stretch of , so many draws give gaps there. Where climbs slowly (gaps that are rare), a thin band of values is spread over a long stretch of , so few draws give gaps there. The gaps produced this way have exactly the CDF .
The first customer arrives one gap after time 0, and each later customer arrives one gap after the customer before.
Task: write arrival_times(uniforms, mean_gap) that turns each draw, in order, into a gap and returns the list of arrival times (minutes since time 0), each rounded to 4 decimal places.
mean_gap is positive.[].