com.netflix.stats.distribution
Class Distribution

java.lang.Object
  extended by com.netflix.stats.distribution.Distribution
All Implemented Interfaces:
DataCollector, DistributionMBean
Direct Known Subclasses:
DataBuffer, Histogram

public class Distribution
extends java.lang.Object
implements DistributionMBean, DataCollector

Accumulator of statistics about a distribution of observed values that are produced incrementally.

Note that the implementation is not synchronized, and simultaneous updates may produce incorrect results. In most cases these incorrect results will be unimportant, but applications that care should synchronize carefully to ensure consistent results.

Note that this implements DistributionMBean and so can be registered as an MBean and accessed via JMX if desired.


Constructor Summary
Distribution()
          Creates a new initially empty Distribution.
 
Method Summary
 void add(Distribution anotherDistribution)
          Add another Distribution's values to this one.
 void clear()
          Clears out the distribution, resetting it to its initial state.
 double getMaximum()
          Get the maximum value found in the distribution.
 double getMean()
          Get the average value in the distribtion.
 double getMinimum()
          Get the minimum value found in the distribution.
 long getNumValues()
          Get the number of values in the distribution.
 double getStdDev()
          Get the standard deviation of values in the distribution.
 double getVariance()
          Get the variance (the square of the standard deviation) of values in the distribution.
 void noteValue(double val)
          Adds a value to the collected data.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Distribution

public Distribution()
Creates a new initially empty Distribution.

Method Detail

noteValue

public void noteValue(double val)
Adds a value to the collected data. This must run very quickly, and so can safely be called in time-critical code.

Specified by:
noteValue in interface DataCollector

clear

public void clear()
Clears out the distribution, resetting it to its initial state.

Specified by:
clear in interface DistributionMBean

getNumValues

public long getNumValues()
Get the number of values in the distribution.

Specified by:
getNumValues in interface DistributionMBean

getMean

public double getMean()
Get the average value in the distribtion.

Specified by:
getMean in interface DistributionMBean

getVariance

public double getVariance()
Get the variance (the square of the standard deviation) of values in the distribution.

Specified by:
getVariance in interface DistributionMBean

getStdDev

public double getStdDev()
Get the standard deviation of values in the distribution.

Specified by:
getStdDev in interface DistributionMBean

getMinimum

public double getMinimum()
Get the minimum value found in the distribution.

Specified by:
getMinimum in interface DistributionMBean

getMaximum

public double getMaximum()
Get the maximum value found in the distribution.

Specified by:
getMaximum in interface DistributionMBean

add

public void add(Distribution anotherDistribution)
Add another Distribution's values to this one.

Parameters:
anotherDistribution - the other Distribution instance

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object