# Tutorial III: Collecting Results¶

In the previous tutorials, we defined and simulated our bank for a week, and saw how to access parts of the simulation engine:

>>> import ciw
>>> N = ciw.create_network(
...     Arrival_distributions=[['Exponential', 0.2]],
...     Service_distributions=[['Exponential', 0.1]],
...     Number_of_servers=[3]
... )
>>> ciw.seed(1)
>>> Q = ciw.Simulation(N)
>>> Q.simulate_until_max_time(1440)


We can quickly get a list of all data records collected by all customers have have finished at least one service, using the get_all_records method of the Simulation object:

>>> recs = Q.get_all_records()


This returns a list of named tuples. Each named tuple contains the following information:

• id_number
• customer_class
• node
• arrival_date
• waiting_time
• service_start_date
• service_time
• service_end_date
• time_blocked
• exit_date
• destination
• queue_size_at_arrival
• queue_size_at_departure

More information on each of these is given in List of Available Results.

Using list comprehension, we can get lists on whichever statistic we like:

>>> # A list of service times
>>> servicetimes = [r.service_time for r in recs]
>>> servicetimes
[2.94463..., 5.96912..., 0.28757..., ..., 10.46244...]

>>> # A list of waits
>>> waits = [r.waiting_time for r in recs]
>>> waits
[0.0, 0.0, 0.20439..., ..., 5.63781...]


Now we can get summary statistics simply by manipulating these lists:

>>> mean_service_time = sum(servicetimes) / len(servicetimes)
>>> mean_service_time
9.543928...

>>> mean_waiting_time = sum(waits) / len(waits)
>>> mean_waiting_time
1.688541...


We now know the mean waiting time of the customers! In next tutorial we will show how to get more representative results (as we have only simulated one given day here).

Further summary statistics can be obtained using external libraries. We recommend numpy, pandas and matplotlib. Using these further statistics and plots can be explored. The histogram of waits below was created using matplotlib, using the following code:

>>> import matplotlib.pyplot as plt
>>> plt.hist(waits);


The next tutorial will show how to use Ciw to get trustworthy results, and finally find out the average waiting time at the bank.