Package org.eclipse.jetty.util.statistic
Class SampleStatistic
- java.lang.Object
-
- org.eclipse.jetty.util.statistic.SampleStatistic
-
public class SampleStatistic extends java.lang.Object
Statistics on a sampled value.
Provides max, total, mean, count, variance, and standard deviation of continuous sequence of samples.
Calculates estimates of mean, variance, and standard deviation characteristics of a sample using a non synchronized approximation of the on-line algorithm presented in Donald Knuth's Art of Computer Programming, Volume 2, Semi numerical Algorithms, 3rd edition, page 232, Boston: Addison-Wesley. That cites a 1962 paper by B.P. Welford: Note on a Method for Calculating Corrected Sums of Squares and Products
This algorithm is also described in Wikipedia in the section "Online algorithm": Algorithms for calculating variance.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicLong
_count
private java.util.concurrent.atomic.LongAccumulator
_max
private java.util.concurrent.atomic.AtomicLong
_total
private java.util.concurrent.atomic.LongAdder
_totalVariance100
-
Constructor Summary
Constructors Constructor Description SampleStatistic()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description long
getCount()
long
getMax()
double
getMean()
double
getStdDev()
long
getTotal()
double
getVariance()
void
record(long sample)
Records a sample value.void
reset()
Resets the statistics.void
set(long sample)
Deprecated.userecord(long)
insteadjava.lang.String
toString()
-
-
-
Field Detail
-
_max
private final java.util.concurrent.atomic.LongAccumulator _max
-
_total
private final java.util.concurrent.atomic.AtomicLong _total
-
_count
private final java.util.concurrent.atomic.AtomicLong _count
-
_totalVariance100
private final java.util.concurrent.atomic.LongAdder _totalVariance100
-
-
Method Detail
-
reset
public void reset()
Resets the statistics.
-
record
public void record(long sample)
Records a sample value.- Parameters:
sample
- the value to record.
-
set
@Deprecated public void set(long sample)
Deprecated.userecord(long)
instead- Parameters:
sample
- the value to record.
-
getMax
public long getMax()
- Returns:
- the max value of the recorded samples
-
getTotal
public long getTotal()
- Returns:
- the sum of all the recorded samples
-
getCount
public long getCount()
- Returns:
- the number of samples recorded
-
getMean
public double getMean()
- Returns:
- the average value of the samples recorded, or zero if there are no samples
-
getVariance
public double getVariance()
- Returns:
- the variance of the samples recorded, or zero if there are less than 2 samples
-
getStdDev
public double getStdDev()
- Returns:
- the standard deviation of the samples recorded
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-