Top Description Fields Constructors Methods
org.eclipse.jetty.util.statistic

public Class SampleStatistic

extends Object
Class Inheritance
Imports
java.util.concurrent.atomic.AtomicLong, .LongAccumulator, .LongAdder

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

Modifier and TypeField and Description
private final AtomicLong
private final LongAccumulator
private final AtomicLong
private final LongAdder

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public long

Returns:

the number of samples recorded
getCount
()

Get the number of samples recorded.

public long

Returns:

the max value of the recorded samples
getMax
()

Get the max value of the recorded samples.

public double

Returns:

the average value of the samples recorded, or zero if there are no samples
getMean
()

Get the average value of the samples recorded, or zero if there are no samples.

public double

Returns:

the standard deviation of the samples recorded
getStdDev
()

Get the standard deviation of the samples recorded.

public long

Returns:

the sum of all the recorded samples
getTotal
()

Get the sum of all the recorded samples.

public double

Returns:

the variance of the samples recorded, or zero if there are less than 2 samples
getVariance
()

Get the variance of the samples recorded, or zero if there are less than 2 samples.

public void
record(long
the value to record.
sample
)

Records a sample value.

public void
reset()

Resets the statistics.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

_countback to summary
private final AtomicLong _count
_maxback to summary
private final LongAccumulator _max
_totalback to summary
private final AtomicLong _total
_totalVariance100back to summary
private final LongAdder _totalVariance100

Constructor Detail

SampleStatisticback to summary
public SampleStatistic()

Method Detail

getCountback to summary
public long getCount()

Get the number of samples recorded.

Returns:long

the number of samples recorded

getMaxback to summary
public long getMax()

Get the max value of the recorded samples.

Returns:long

the max value of the recorded samples

getMeanback to summary
public double getMean()

Get the average value of the samples recorded, or zero if there are no samples.

Returns:double

the average value of the samples recorded, or zero if there are no samples

getStdDevback to summary
public double getStdDev()

Get the standard deviation of the samples recorded.

Returns:double

the standard deviation of the samples recorded

getTotalback to summary
public long getTotal()

Get the sum of all the recorded samples.

Returns:long

the sum of all the recorded samples

getVarianceback to summary
public double getVariance()

Get the variance of the samples recorded, or zero if there are less than 2 samples.

Returns:double

the variance of the samples recorded, or zero if there are less than 2 samples

recordback to summary
public void record(long sample)

Records a sample value.

Parameters
sample:long

the value to record.

resetback to summary
public void reset()

Resets the statistics.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override