org.apache.spark.util
Class StatCounter

Object
  extended by org.apache.spark.util.StatCounter
All Implemented Interfaces:
java.io.Serializable

public class StatCounter
extends Object
implements scala.Serializable

A class for tracking the statistics of a set of numbers (count, mean and variance) in a numerically robust way. Includes support for merging two StatCounters. Based on Welford and Chan's algorithms for running variance.

See Also:
Serialized Form

Constructor Summary
StatCounter()
          Initialize the StatCounter with no values.
StatCounter(scala.collection.TraversableOnce<Object> values)
           
 
Method Summary
static StatCounter apply(scala.collection.Seq<Object> values)
          Build a StatCounter from a list of values passed as variable-length arguments.
static StatCounter apply(scala.collection.TraversableOnce<Object> values)
          Build a StatCounter from a list of values.
 StatCounter copy()
          Clone this StatCounter
 long count()
           
 double max()
           
 double mean()
           
 StatCounter merge(double value)
          Add a value into this StatCounter, updating the internal statistics.
 StatCounter merge(StatCounter other)
          Merge another StatCounter into this one, adding up the internal statistics.
 StatCounter merge(scala.collection.TraversableOnce<Object> values)
          Add multiple values into this StatCounter, updating the internal statistics.
 double min()
           
 double sampleStdev()
          Return the sample standard deviation of the values, which corrects for bias in estimating the variance by dividing by N-1 instead of N.
 double sampleVariance()
          Return the sample variance, which corrects for bias in estimating the variance by dividing by N-1 instead of N.
 double stdev()
          Return the standard deviation of the values.
 double sum()
           
 String toString()
           
 double variance()
          Return the variance of the values.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StatCounter

public StatCounter(scala.collection.TraversableOnce<Object> values)

StatCounter

public StatCounter()
Initialize the StatCounter with no values.

Method Detail

apply

public static StatCounter apply(scala.collection.TraversableOnce<Object> values)
Build a StatCounter from a list of values.


apply

public static StatCounter apply(scala.collection.Seq<Object> values)
Build a StatCounter from a list of values passed as variable-length arguments.


merge

public StatCounter merge(double value)
Add a value into this StatCounter, updating the internal statistics.


merge

public StatCounter merge(scala.collection.TraversableOnce<Object> values)
Add multiple values into this StatCounter, updating the internal statistics.


merge

public StatCounter merge(StatCounter other)
Merge another StatCounter into this one, adding up the internal statistics.


copy

public StatCounter copy()
Clone this StatCounter


count

public long count()

mean

public double mean()

sum

public double sum()

max

public double max()

min

public double min()

variance

public double variance()
Return the variance of the values.


sampleVariance

public double sampleVariance()
Return the sample variance, which corrects for bias in estimating the variance by dividing by N-1 instead of N.

Returns:
(undocumented)

stdev

public double stdev()
Return the standard deviation of the values.


sampleStdev

public double sampleStdev()
Return the sample standard deviation of the values, which corrects for bias in estimating the variance by dividing by N-1 instead of N.

Returns:
(undocumented)

toString

public String toString()
Overrides:
toString in class Object