|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--Utility.Tally
Statistic Collection Objects
The Tally class is used for collecting simple statistics
for a set of numbers. It provides functions to compute min, max,
variance, standard deviation, sum, and sum of squares.
All values are represented using doubles.
Note that the original source code for these classes was
written by Zhonge Xiao in C++. The C++ code was ported
over to Java and some minor design changes were made.
Field Summary | |
protected double |
fCount
Count of values in the tally. |
protected java.util.Vector |
fDataPoints
|
protected double |
fMax
Maximum value in the tally. |
protected double |
fMin
Minimum value in the tally. |
protected java.lang.String |
fName
The name of the tally. |
protected double |
fSum
Sum of the values in the tally. |
protected double |
fSumSq
Sum of the squares in the tally. |
static java.lang.String |
seperator
Represents the string used for seperating consecutive numerical values. |
static boolean |
STORE_POINTS
|
static boolean |
SUMMARY_ONLY
|
static boolean |
WITH_HEADER
|
static boolean |
WO_HEADER
|
Constructor Summary | |
Tally()
Initialize the object. |
|
Tally(java.lang.String name,
boolean storePoints)
Initialize the object, give the Tally a name. |
Method Summary | |
double |
average()
Report the mean data point. |
double |
count()
Report how many data points are in the tally. |
boolean |
isStoringPoints()
Report whether or not this Tally object is storing the actual data points. |
double |
max()
Report the maximum data point. |
double |
min()
Report the minimum data point. |
void |
outputPoints(java.io.PrintStream out,
boolean withHeader)
Output all the data points stored in the Tally object. |
void |
outputSummary(java.io.PrintStream out,
boolean withHeader)
Output the summary statistics that were collected for the Tally. |
void |
reset()
Remove all data points from the Tally. |
double |
stdDev()
Report the standard deviation of the data points. |
double |
sum()
Report the sum of the data points. |
double |
sumSq()
Report the sum of the squares of the data points. |
void |
update(double x)
Updates the statistics with the data item x. |
void |
updateBatch(Tally data)
Update Tally with batch data. |
double |
variance()
Report the variance of the data points. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected double fCount
protected double fSum
protected double fSumSq
protected double fMin
protected double fMax
protected java.lang.String fName
public static final boolean STORE_POINTS
public static final boolean SUMMARY_ONLY
protected java.util.Vector fDataPoints
public static final boolean WITH_HEADER
public static final boolean WO_HEADER
public static java.lang.String seperator
Constructor Detail |
public Tally()
public Tally(java.lang.String name, boolean storePoints)
name
- The name of the Tally object. This will
be used with the output functions.storePoints
- Whether or not the Tally should record
all individiual data points. Tally.STORE_POINTS means
the object should store data points, and Tally.SUMMARY_ONLY
means the object should only compute summary statistics.Method Detail |
public void reset()
public void update(double x)
x
- The value to record in the tally.public void updateBatch(Tally data)
data
- The tally whose data will be added to this
tally.
java.lang.RuntimeException
- A RuntimeException is thrown
if the Tally object data is not storing data points
but the current Tally object is. There is no problem
however if we are not storing points but the data object
is.public double count()
public double sum()
public double sumSq()
public double min()
public double max()
public double average()
public double stdDev()
public double variance()
public void outputPoints(java.io.PrintStream out, boolean withHeader)
out
- The PrintStream to send the output to.withHeader
- true to print a header, false to skip
the header. Tally.WITH_HEADER and Tally.WO_HEADER can
be used instead of true and false.
java.lang.RuntimeException
- A RuntimeException is thrown
if the Tally object is not currently storing data points.public void outputSummary(java.io.PrintStream out, boolean withHeader)
out
- The PrintStream to send the output to.withHeader
- true to print a header, false to skip
the header. Tally.WITH_HEADER and Tally.WO_HEADER can
be used instead of true and false.public boolean isStoringPoints()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |