Commit 504999f9 authored by Raymond Hettinger's avatar Raymond Hettinger

Simplify code in an example

parent 9cf46bda
...@@ -429,12 +429,12 @@ Simulation of arrival times and service deliveries in a single server queue:: ...@@ -429,12 +429,12 @@ Simulation of arrival times and service deliveries in a single server queue::
num_waiting = 0 num_waiting = 0
arrival = service_end = 0.0 arrival = service_end = 0.0
for i in range(10000): for i in range(20000):
num_waiting += 1 if arrival <= service_end:
arrival += expovariate(1.0 / average_arrival_interval) num_waiting += 1
print(f'{arrival:6.1f} arrived') arrival += expovariate(1.0 / average_arrival_interval)
print(f'{arrival:6.1f} arrived')
while arrival > service_end: else:
num_waiting -= 1 num_waiting -= 1
service_start = service_end if num_waiting else arrival service_start = service_end if num_waiting else arrival
service_time = gauss(average_service_time, stdev_service_time) service_time = gauss(average_service_time, stdev_service_time)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment