statistics
The statistics objects collect observations and produce summarized information about the observations, such as the mean, standard deviation, minimum value, and maximum value. The statistics module has four types of statistics objects in three different families.
The statistics objects are:
The Counter that collects integer values, such as the occurrences of an event, and produces the count as the statistics result. The counter receives its observations through a method
register(int_value)
The Tally that collects floating point values such as processing times, and produces statistics results such as the mean, standard deviation, and variance of the submitted values. The Tally receives its observations through a method
register(float_value)
The WeightedTally that collects floating point values with an associated weight factor, for example the number of entities in a queue as the observations and the duration of the particular queue length as the weights, and produces results such as weighted average and weighted variance of the observations. The WeightedTally receives its observations through a method
register(float_weight, float_value)
The TimestampWeightedTally that is a specialization of the WeightedTally where the weights are derived automatically from the intervals between timestamps. Each observation is provided with the time when the value of a property changed. The TimestampWeightedTally receives its observations through a method
register(float_timestamp, float_value)
The statistics families are:
Ordinary statistics. These receive the observations by explicitly calling the register method for any of the four statistics. The classes are Counter, Tally, WeightedTally, and TimestampWeightedTally.
Event-based statistics. These receive the observations by listening to an EventProducer (see the pubsub.py module) that ‘fires’ events to one or more listeners, among which the Event-based statistics. This way, the statistic gathering and processing is decoupled from the process in the simulation that generates the data: there can be zero, one, or many statistics listeners for each data producing object in the simulation. The Event-based statistics also fire events with the values of the calculated statistics values, so a GUI-element such as a graph or table can be automatically updated when values of the statistic change. The classes extend the ‘ordinary statistics’, and are called EventBasedCounter, EventBasedTally, EventBasedWeightedTally, and EventBasedTimestampWeightedTally.
Simulation statistics. These receive the observations in the same way as the Event-based statistics, but are also aware of the Simulator. This means they can subscribe to the Simulator’s WARMUP_EVENT taking care that the statistics are initialized appropriately. Additionally, the SimPersistent class that extends EventBasedTimestampWeightedTally can retrieve the timestamps directly from the Simulator. Additionally, the Simulation Statistics register themselves in the model as output statistics when the model has been defined when they are created. Note that this is the case when the statistics are defined in the construct_model method of the Model, but not when they are defined in the constructor of the Model. The Simulation Statistics classes are:
SimCounter extending EventBasedCounter
SimTally extending EventBasedTally
SimWeightedTally, extending EventBasedWeightedTally
SimPersistent, extending EventBasedTimestampWeightedTally
Examples
SimCounter is used in discrete-event simulation to count the number of occurrences in a model, such as the number of generated entities, or the number of processed entities by a server.
SimTally is used in discrete-event simulation to calculate statistics for the waiting time in a queue, the time-in-system of an entity, or the processing time at a server.
SimPersistent is used in discrete-event simulation to calculate statistics for the length of a queue or the utilization of a server.
Notes
The average of the SimTally can be calculated as:
where \(x_{i}\) are the observations and \(n\) is the number of observations (only observations after the warmup time are included).
The average of the SimPersistent can be calculated as:
where \(x_{t}\) is the stepwise changing x-value (it changes at each observation) and \(T\) is the total time of the simulation (after the warmup time). it can be through of as the time-normalized surface ‘under’ the curve of the observed variable.
Click below for the API of a specific output statistic type.
Base Statistics Classes
- Counter
- Tally
Tally
Tally.__init__()
Tally.initialize()
Tally.name
Tally.register()
Tally.n()
Tally.min()
Tally.max()
Tally.sum()
Tally.mean()
Tally.confidence_interval()
Tally.variance()
Tally.stdev()
Tally.skewness()
Tally.kurtosis()
Tally.excess_kurtosis()
Tally.report_header()
Tally.report_line()
Tally.report_footer()
- WeightedTally
WeightedTally
WeightedTally.__init__()
WeightedTally.initialize()
WeightedTally.name
WeightedTally.register()
WeightedTally.n()
WeightedTally.min()
WeightedTally.max()
WeightedTally.weighted_sum()
WeightedTally.weighted_mean()
WeightedTally.weighted_variance()
WeightedTally.weighted_stdev()
WeightedTally.report_header()
WeightedTally.report_line()
WeightedTally.report_footer()
- TimestampWeightedTally
TimestampWeightedTally
TimestampWeightedTally.__init__()
TimestampWeightedTally.initialize()
TimestampWeightedTally.isactive()
TimestampWeightedTally.end_observations()
TimestampWeightedTally.last_value()
TimestampWeightedTally.register()
TimestampWeightedTally.max()
TimestampWeightedTally.min()
TimestampWeightedTally.n()
TimestampWeightedTally.name
TimestampWeightedTally.report_footer()
TimestampWeightedTally.report_header()
TimestampWeightedTally.report_line()
TimestampWeightedTally.weighted_mean()
TimestampWeightedTally.weighted_stdev()
TimestampWeightedTally.weighted_sum()
TimestampWeightedTally.weighted_variance()
Event-Based Statistics Classes
- EventBasedCounter
EventBasedCounter
EventBasedCounter.__init__()
EventBasedCounter.initialize()
EventBasedCounter.notify()
EventBasedCounter.register()
EventBasedCounter.add_listener()
EventBasedCounter.count()
EventBasedCounter.has_listeners()
EventBasedCounter.n()
EventBasedCounter.name
EventBasedCounter.remove_all_listeners()
EventBasedCounter.remove_listener()
EventBasedCounter.report_footer()
EventBasedCounter.report_header()
EventBasedCounter.report_line()
- EventBasedTally
EventBasedTally
EventBasedTally.__init__()
EventBasedTally.initialize()
EventBasedTally.notify()
EventBasedTally.register()
EventBasedTally.add_listener()
EventBasedTally.confidence_interval()
EventBasedTally.excess_kurtosis()
EventBasedTally.has_listeners()
EventBasedTally.kurtosis()
EventBasedTally.max()
EventBasedTally.mean()
EventBasedTally.min()
EventBasedTally.n()
EventBasedTally.name
EventBasedTally.remove_all_listeners()
EventBasedTally.remove_listener()
EventBasedTally.report_footer()
EventBasedTally.report_header()
EventBasedTally.report_line()
EventBasedTally.skewness()
EventBasedTally.stdev()
EventBasedTally.sum()
EventBasedTally.variance()
- EventBasedWeightedTally
EventBasedWeightedTally
EventBasedWeightedTally.__init__()
EventBasedWeightedTally.initialize()
EventBasedWeightedTally.notify()
EventBasedWeightedTally.register()
EventBasedWeightedTally.add_listener()
EventBasedWeightedTally.has_listeners()
EventBasedWeightedTally.max()
EventBasedWeightedTally.min()
EventBasedWeightedTally.n()
EventBasedWeightedTally.name
EventBasedWeightedTally.remove_all_listeners()
EventBasedWeightedTally.remove_listener()
EventBasedWeightedTally.report_footer()
EventBasedWeightedTally.report_header()
EventBasedWeightedTally.report_line()
EventBasedWeightedTally.weighted_mean()
EventBasedWeightedTally.weighted_stdev()
EventBasedWeightedTally.weighted_sum()
EventBasedWeightedTally.weighted_variance()
- EventBasedTimestampWeightedTally
EventBasedTimestampWeightedTally
EventBasedTimestampWeightedTally.__init__()
EventBasedTimestampWeightedTally.initialize()
EventBasedTimestampWeightedTally.notify()
EventBasedTimestampWeightedTally.register()
EventBasedTimestampWeightedTally.add_listener()
EventBasedTimestampWeightedTally.end_observations()
EventBasedTimestampWeightedTally.has_listeners()
EventBasedTimestampWeightedTally.isactive()
EventBasedTimestampWeightedTally.last_value()
EventBasedTimestampWeightedTally.max()
EventBasedTimestampWeightedTally.min()
EventBasedTimestampWeightedTally.n()
EventBasedTimestampWeightedTally.name
EventBasedTimestampWeightedTally.remove_all_listeners()
EventBasedTimestampWeightedTally.remove_listener()
EventBasedTimestampWeightedTally.report_footer()
EventBasedTimestampWeightedTally.report_header()
EventBasedTimestampWeightedTally.report_line()
EventBasedTimestampWeightedTally.weighted_mean()
EventBasedTimestampWeightedTally.weighted_stdev()
EventBasedTimestampWeightedTally.weighted_sum()
EventBasedTimestampWeightedTally.weighted_variance()
Simulation-Specific Statistics Classes
- SimCounter
SimCounter
SimCounter.__init__()
SimCounter.listen_to()
SimCounter.key
SimCounter.simulator
SimCounter.notify()
SimCounter.add_listener()
SimCounter.count()
SimCounter.has_listeners()
SimCounter.initialize()
SimCounter.n()
SimCounter.name
SimCounter.register()
SimCounter.remove_all_listeners()
SimCounter.remove_listener()
SimCounter.report_footer()
SimCounter.report_header()
SimCounter.report_line()
- SimTally
SimTally
SimTally.__init__()
SimTally.listen_to()
SimTally.key
SimTally.simulator
SimTally.notify()
SimTally.add_listener()
SimTally.confidence_interval()
SimTally.excess_kurtosis()
SimTally.has_listeners()
SimTally.initialize()
SimTally.kurtosis()
SimTally.max()
SimTally.mean()
SimTally.min()
SimTally.n()
SimTally.name
SimTally.register()
SimTally.remove_all_listeners()
SimTally.remove_listener()
SimTally.report_footer()
SimTally.report_header()
SimTally.report_line()
SimTally.skewness()
SimTally.stdev()
SimTally.sum()
SimTally.variance()
- SimWeightedTally
SimWeightedTally
SimWeightedTally.__init__()
SimWeightedTally.listen_to()
SimWeightedTally.key
SimWeightedTally.simulator
SimWeightedTally.notify()
SimWeightedTally.add_listener()
SimWeightedTally.has_listeners()
SimWeightedTally.initialize()
SimWeightedTally.max()
SimWeightedTally.min()
SimWeightedTally.n()
SimWeightedTally.name
SimWeightedTally.register()
SimWeightedTally.remove_all_listeners()
SimWeightedTally.remove_listener()
SimWeightedTally.report_footer()
SimWeightedTally.report_header()
SimWeightedTally.report_line()
SimWeightedTally.weighted_mean()
SimWeightedTally.weighted_stdev()
SimWeightedTally.weighted_sum()
SimWeightedTally.weighted_variance()
- SimPersistent
SimPersistent
SimPersistent.__init__()
SimPersistent.listen_to()
SimPersistent.key
SimPersistent.simulator
SimPersistent.notify()
SimPersistent.add_listener()
SimPersistent.end_observations()
SimPersistent.has_listeners()
SimPersistent.initialize()
SimPersistent.isactive()
SimPersistent.last_value()
SimPersistent.max()
SimPersistent.min()
SimPersistent.n()
SimPersistent.name
SimPersistent.register()
SimPersistent.remove_all_listeners()
SimPersistent.remove_listener()
SimPersistent.report_footer()
SimPersistent.report_header()
SimPersistent.report_line()
SimPersistent.weighted_mean()
SimPersistent.weighted_stdev()
SimPersistent.weighted_sum()
SimPersistent.weighted_variance()