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:

  1. 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.

  2. 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.

  3. 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:

\[\mu = \sum_{i=1}^{n}{\frac{x_{i}}{n}}\]

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:

\[\mu = \int_{0}^{T}{\frac{x_{t}}{T} dt}\]

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

Event-Based Statistics Classes

Simulation-Specific Statistics Classes