

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object org.jboss.dna.common.statistic.SimpleStatistics<T> org.jboss.dna.common.statistic.DetailedStatistics<T>
T
 the number type for these statistics@ThreadSafe public class DetailedStatistics<T extends Number>
Encapsulation of the statistics for a series of values to which new values are frequently added. The statistics include the
minimum
, maximum
, total (aggregate sum)
,
mean (average)
, median
, standard deviation
and the
histogram
of the values.
This class uses an efficient running calculation of the mean and standard deviation that is not as susceptible to roundoff errors as other traditional algorithms. The recursive algorithm is as follows, where M is the median value, sigma is the standard deviation, and S is a variable used in the calculation of sigma:
M(1) = x(1) S(1) = 0 M(k) = M(k1) + ( x(k)  M(k1) ) / k S(k) = S(k1) + ( x(k)  M(k1) ) * (x(k)  M(k))Then, the standard deviation for n values in x is
sigma = sqrt(S(n) / n)Unlike the other quantities, the median value (the value at which half of the values are greater and half the values are lower) cannot be calculated incrementally. Therefore, this class does record the values so that the median can be properly calculated. This fact should be kept in mind when performing statistics on large numbers of values.
This class is threadsafe.
Constructor Summary  

DetailedStatistics(MathOperations<T> operations)

Method Summary  

Histogram<T> 
getHistogram()
Return the histogram of the values . 
Histogram<T> 
getHistogram(int numSigmas)
Return the histogram of the values . 
T 
getMedian()
Return the approximate mean (average) value represented as an instance of the operand type. 
double 
getMedianValue()
Return the median value. 
double 
getStandardDeviation()
Return the standard deviation. 
List<T> 
getValues()
Get the values that have been recorded in these statistics. 
String 
toString()

Methods inherited from class org.jboss.dna.common.statistic.SimpleStatistics 

add, getCount, getMathOperations, getMaximum, getMean, getMeanValue, getMinimum, getTotal, reset 
Methods inherited from class java.lang.Object 

equals, getClass, hashCode, notify, notifyAll, wait, wait, wait 
Constructor Detail 

public DetailedStatistics(MathOperations<T> operations)
Method Detail 

public List<T> getValues()
added
in another thread.
public T getMedian()
getMedianValue()
.
count
is 0public double getMedianValue()
count
is 0getMedian()
public double getStandardDeviation()
count
is 0 or if all of the values are the same.public Histogram<T> getHistogram()
values
. This method returns a histogram where all of the buckets are
distributed normally and all have the same width. In this case, the 'numSigmas' should be set to 0. For other variations,
see getHistogram(int)
.
getHistogram(int)
public Histogram<T> getHistogram(int numSigmas)
values
. This method is capable of creating two kinds of histograms. The
first kind is a histogram where all of the buckets are distributed normally and all have the same width. In this case, the
'numSigmas' should be set to 0. See getHistogram()
.
The second kind of histogram is more useful when most of the data that is clustered near one value. This histogram is
focused around the values that are up to 'numSigmas' above and below the median
, and all values
outside of this range are placed in the first and last bucket.
numSigmas
 the number of standard deviations from the median
, or 0 if the buckets of the
histogram should be evenly distributed
getHistogram()
public String toString()
toString
in class SimpleStatistics<T extends Number>


PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 