Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8ab1258

Browse files
committed
Simplify code in an example
1 parent 23bb6f4 commit 8ab1258

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

Doc/library/random.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -429,12 +429,12 @@ Simulation of arrival times and service deliveries in a single server queue::
429429

430430
num_waiting = 0
431431
arrival = service_end = 0.0
432-
for i in range(10000):
433-
num_waiting += 1
434-
arrival += expovariate(1.0 / average_arrival_interval)
435-
print(f'{arrival:6.1f} arrived')
436-
437-
while arrival > service_end:
432+
for i in range(20000):
433+
if arrival <= service_end:
434+
num_waiting += 1
435+
arrival += expovariate(1.0 / average_arrival_interval)
436+
print(f'{arrival:6.1f} arrived')
437+
else:
438438
num_waiting -= 1
439439
service_start = service_end if num_waiting else arrival
440440
service_time = gauss(average_service_time, stdev_service_time)

0 commit comments

Comments
 (0)