ikr.simlib.statistics.median

## Class MedianStatistic

• All Implemented Interfaces:
Printable
Direct Known Subclasses:
StdMedianStatistic

public abstract class MedianStatistic
extends Statistic
implements Printable
The classes  MedianStatistic  or StdMedianStatistic serve to register single measured values (e.g., run times) of the type  double  with the help of the method update(double).

The following functions are available for evaluation: If the parameter maxBufferSize is set to zero, all samples will be stored internally and the median will be calculated at the end of the simulation. Since this is very memory consuming, maxBufferSize can be set to a number > 0, which determines the maximum number of samples the statistic should hold in memory. The median is then calculated at the end of the simulation as an approximation that is based on all samples.

For printing the results it defines the following keywords:

median
Median value of all measured values in reference to all batches
cintm
confidence interval to median value
max
maximum sample of all batches
min
minimum sample of all batches
bmedian
number of samples in actual Batch
The calculation of the median usually needs to buffer all measured values. In order to save memory an approximation algorithm is served by the median statistic class:
• all values are saved in a list of value pairs of one double (value) and one integer value (weight)
• the weight is set to 1 for every new value added to the list
• when the list size exceeds the maximum buffer size, all entries are sorted by the value and grouped to pairs by adding their weight and calculating like this:
value = value1 · weight1 + value2 · weight2
• When the method getMedian() is called the list is sorted again by value. Then the list is iterated from beginning until the sum of the weight-values is larger than the half of the total sum of weights. After this the found item and the previous item are selected and an linear approximation between the two value pairs is done.
MedianTimeMeter

• ### Fields inherited from class ikr.simlib.statistics.Statistic

sampleIndex, simNode, traceWriter
• ### Constructor Summary

Constructors
Constructor and Description
MedianStatistic(SimNode ownNode)
• ### Method Summary

Methods
Modifier and Type Method and Description
abstract long getBatchEvents()
abstract double getBatchMedian()
abstract long getEvents()
abstract double getMaximum()
abstract double getMedian()
abstract double getMedianConfidenceInterval()
abstract double getMinimum()
java.lang.String getResultTypeName()
void printResults(ResultType type, PrintResultWriter writer)
abstract void update(double sample)
• ### Methods inherited from class ikr.simlib.statistics.Statistic

addResultTag, addResultTag, computeMeasures, disableTracing, enableTracing, handleInitSimulation, handleStartBatch, handleStartTransientPhase, handleStopBatch, handleStopTransientPhase, printComments, resetBatchStatistic, resetStatistic, update, writeTraceEntry
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Constructor Detail

• #### MedianStatistic

public MedianStatistic(SimNode ownNode)
• ### Method Detail

• #### printResults

public void printResults(ResultType type,
PrintResultWriter writer)
Specified by:
printResults in interface Printable
• #### getResultTypeName

public java.lang.String getResultTypeName()
Specified by:
getResultTypeName in interface Printable
• #### update

public abstract void update(double sample)
• #### getMedian

public abstract double getMedian()
• #### getMedianConfidenceInterval

public abstract double getMedianConfidenceInterval()
• #### getEvents

public abstract long getEvents()
• #### getMaximum

public abstract double getMaximum()
• #### getMinimum

public abstract double getMinimum()
• #### getBatchMedian

public abstract double getBatchMedian()
• #### getBatchEvents

public abstract long getBatchEvents()