Package org.apache.spark.util
Class StatCounter
Object
org.apache.spark.util.StatCounter
- All Implemented Interfaces:
- 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:
- 
Constructor SummaryConstructorsConstructorDescriptionInitialize the StatCounter with no values.StatCounter(scala.collection.IterableOnce<Object> values) 
- 
Method SummaryModifier and TypeMethodDescriptionstatic StatCounterBuild a StatCounter from a list of values passed as variable-length arguments.static StatCounterBuild a StatCounter from a list of values.copy()Clone this StatCounterlongcount()doublemax()doublemean()merge(double value) Add a value into this StatCounter, updating the internal statistics.merge(StatCounter other) Merge another StatCounter into this one, adding up the internal statistics.Add multiple values into this StatCounter, updating the internal statistics.doublemin()doublepopStdev()Return the population standard deviation of the values.doubleReturn the population variance of the values.doubleReturn the sample standard deviation of the values, which corrects for bias in estimating the variance by dividing by N-1 instead of N.doubleReturn the sample variance, which corrects for bias in estimating the variance by dividing by N-1 instead of N.doublestdev()Return the population standard deviation of the values.doublesum()toString()doublevariance()Return the population variance of the values.
- 
Constructor Details- 
StatCounter
- 
StatCounterpublic StatCounter()Initialize the StatCounter with no values.
 
- 
- 
Method Details- 
applyBuild a StatCounter from a list of values.
- 
applyBuild a StatCounter from a list of values passed as variable-length arguments.
- 
mergeAdd a value into this StatCounter, updating the internal statistics.
- 
mergeAdd multiple values into this StatCounter, updating the internal statistics.
- 
mergeMerge another StatCounter into this one, adding up the internal statistics.
- 
copyClone this StatCounter
- 
countpublic long count()
- 
meanpublic double mean()
- 
sumpublic double sum()
- 
maxpublic double max()
- 
minpublic double min()
- 
variancepublic double variance()Return the population variance of the values.
- 
popVariancepublic double popVariance()Return the population variance of the values.- Returns:
- (undocumented)
 
- 
sampleVariancepublic double sampleVariance()Return the sample variance, which corrects for bias in estimating the variance by dividing by N-1 instead of N.- Returns:
- (undocumented)
 
- 
stdevpublic double stdev()Return the population standard deviation of the values.
- 
popStdevpublic double popStdev()Return the population standard deviation of the values.- Returns:
- (undocumented)
 
- 
sampleStdevpublic 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
 
-