bcds.tools.stat
Class SimpleAvg

java.lang.Object
  extended by bcds.tools.stat.CollectorBase
      extended by bcds.tools.stat.SimpleAvg
All Implemented Interfaces:
Collector
Direct Known Subclasses:
Average

public class SimpleAvg
extends CollectorBase

Implements a collector that produces as result the arithmetic mean of its observations. The maximum number of observations supported is 2^31.

Author:
Juan Segovia S.

Constructor Summary
SimpleAvg()
          Default constructor.
SimpleAvg(java.lang.String name, java.lang.String desc)
          Creates a new collector of the given name.
 
Method Summary
 void collect(double value)
          Registers a new observation; it keeps the sum of the observations and a counter, so that the arithmetic mean can be calculated.
 double getAverage()
           
 int getCount()
          Returns the number of observations recorded by this collector.
 double[] getResults()
          Returns the average and the number of observations.
 java.lang.String[] getResultsLabels()
          Returns {"average", "count"}.
 void setup(java.lang.String name, java.lang.String desc)
          Resets this collector.
 
Methods inherited from class bcds.tools.stat.CollectorBase
equals, getDescription, getName, hashCode, report, report, report, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleAvg

public SimpleAvg()
Default constructor.


SimpleAvg

public SimpleAvg(java.lang.String name,
                 java.lang.String desc)
Creates a new collector of the given name.

Method Detail

setup

public void setup(java.lang.String name,
                  java.lang.String desc)
Resets this collector.

Specified by:
setup in interface Collector
Overrides:
setup in class CollectorBase

collect

public void collect(double value)
Registers a new observation; it keeps the sum of the observations and a counter, so that the arithmetic mean can be calculated.


getResults

public double[] getResults()
Returns the average and the number of observations.


getResultsLabels

public java.lang.String[] getResultsLabels()
Returns {"average", "count"}.


getAverage

public double getAverage()

getCount

public int getCount()
Returns the number of observations recorded by this collector.