org.apache.hadoop.metrics2.util
Class SampleStat

java.lang.Object
  extended by org.apache.hadoop.metrics2.util.SampleStat

public class SampleStat
extends Object

Helper to compute running sample stats


Nested Class Summary
static class SampleStat.MinMax
          Helper to keep running min/max
 
Constructor Summary
SampleStat()
          Construct a new running sample stat
 
Method Summary
 SampleStat add(double x)
          Add a sample the running stat.
 SampleStat add(long nSamples, double x)
          Add some sample and a partial sum to the running stat.
 void copyTo(SampleStat other)
          Copy the values to other (saves object creation and gc.)
 double max()
           
 double mean()
           
 double min()
           
 long numSamples()
           
 void reset()
           
 double stddev()
           
 double variance()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SampleStat

public SampleStat()
Construct a new running sample stat

Method Detail

reset

public void reset()

copyTo

public void copyTo(SampleStat other)
Copy the values to other (saves object creation and gc.)

Parameters:
other - the destination to hold our values

add

public SampleStat add(double x)
Add a sample the running stat.

Parameters:
x - the sample number
Returns:
self

add

public SampleStat add(long nSamples,
                      double x)
Add some sample and a partial sum to the running stat. Note, min/max is not evaluated using this method.

Parameters:
nSamples - number of samples
x - the partial sum
Returns:
self

numSamples

public long numSamples()
Returns:
the total number of samples

mean

public double mean()
Returns:
the arithmetic mean of the samples

variance

public double variance()
Returns:
the variance of the samples

stddev

public double stddev()
Returns:
the standard deviation of the samples

min

public double min()
Returns:
the minimum value of the samples

max

public double max()
Returns:
the maximum value of the samples


Copyright © 2009 The Apache Software Foundation