peersim.util
Class MedianStats

java.lang.Object
  extended by peersim.util.IncrementalStats
      extended by peersim.util.MedianStats

public class MedianStats
extends IncrementalStats

This class adds the ability to retrieve the median element to the IncrementalStats class. Note that this class actually stores all the elements, so (unlike in its superclass) storage requirements depend on the number of items processed.


Constructor Summary
MedianStats()
          Calls reset().
 
Method Summary
 void add(double item, int k)
          Updates the statistics assuming element item is added k times.
 double getMedian()
          Retrieves the median in the current data collection.
static void main(java.lang.String[] args)
           
 void reset()
          Resets the statistics to reflect the zero elements set.
 
Methods inherited from class peersim.util.IncrementalStats
add, getAverage, getMax, getMaxCount, getMin, getMinCount, getN, getSqrSum, getStD, getSum, getVar, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MedianStats

public MedianStats()
Calls reset().

Method Detail

getMedian

public double getMedian()
Retrieves the median in the current data collection.

Returns:
The current median value.

add

public void add(double item,
                int k)
Description copied from class: IncrementalStats
Updates the statistics assuming element item is added k times.

Overrides:
add in class IncrementalStats

reset

public void reset()
Description copied from class: IncrementalStats
Resets the statistics to reflect the zero elements set. Min and max are set to positive and negative infinity, respectively.

Overrides:
reset in class IncrementalStats

main

public static void main(java.lang.String[] args)