Utility
Class WeightedTally

java.lang.Object
  |
  +--Utility.Tally
        |
        +--Utility.WeightedTally
Direct Known Subclasses:
TimeSeriesTally

public class WeightedTally
extends Tally

The WeightedTally class is for weighted tallying of values. It extends the Tally class.
Unfortunately, SimKit does not (yet) give the programmer access to either the current event or the current simulation time. This means that there is no method of providing a time weighted tally where the time weights are automatically calculated.

See Also:
Tally

Field Summary
protected  java.util.Vector fWeights
           
 
Fields inherited from class Utility.Tally
fCount, fDataPoints, fMax, fMin, fName, fSum, fSumSq, seperator, STORE_POINTS, SUMMARY_ONLY, WITH_HEADER, WO_HEADER
 
Constructor Summary
WeightedTally()
           
WeightedTally(java.lang.String name, boolean storePoints)
          Initialize the object, give the Tally a name.
 
Method Summary
 double average()
          Report the weighted mean of the data points.
 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 WeightedTally.
 void reset()
          Remove all data points from the Tally.
 double stdDev()
          Report the standard deviation of the data points.
 double sumWeights()
           
 void update(double x)
          Add a data point to the tally.
 void update(double x, double weight)
          Updates the statistics with the weighted new value.
 void updateBatch(Tally data)
          Update Tally with batch data.
 double variance()
          Report the variance of the data points.
 
Methods inherited from class Utility.Tally
count, isStoringPoints, max, min, sum, sumSq
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fWeights

protected java.util.Vector fWeights
Constructor Detail

WeightedTally

public WeightedTally()

WeightedTally

public WeightedTally(java.lang.String name,
                     boolean storePoints)
Initialize the object, give the Tally a name.

Parameters:
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

reset

public void reset()
Description copied from class: Tally
Remove all data points from the Tally.

Overrides:
reset in class Tally

update

public void update(double x)
Add a data point to the tally. Assume that if no weight is specified, a weight of 1 should be assigned.

Overrides:
update in class Tally
Parameters:
x - The value to add to the tally.

update

public void update(double x,
                   double weight)
Updates the statistics with the weighted new value.

Parameters:
x - The value to add to statistics
weight - The weight to use for this value

updateBatch

public void updateBatch(Tally data)
Update Tally with batch data.

Overrides:
updateBatch in class Tally
Parameters:
data - The Tally whose data will be added to this tally. For now, this should be an instance of WeightedTally. Later on, other types of Tallies may be supported.
Throws:
java.lang.RuntimeException - A RuntimeException is thrown if the Tally object data is not an instance of WeightedTally.

average

public double average()
Report the weighted mean of the data points.

Overrides:
average in class Tally
Returns:
The weighted mean of the values in the tally. If there are no values in the tally then 0 is returned.

variance

public double variance()
Report the variance of the data points.

Overrides:
variance in class Tally
Returns:
The sample variance of the values in the tally. If there are fewer than 2 values in the tally or the sum of the weights is not positive, then 0 is returned.

sumWeights

public double sumWeights()

stdDev

public double stdDev()
Report the standard deviation of the data points.

Overrides:
stdDev in class Tally
Returns:
The standard deviation of the values in the tally. If there are fewer than 2 values in the tally or the sum of the weights is not positive, then 0 is returned.

outputPoints

public void outputPoints(java.io.PrintStream out,
                         boolean withHeader)
Output all the data points stored in the Tally object.

Overrides:
outputPoints in class Tally
Parameters:
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.
Throws:
java.lang.RuntimeException - A RuntimeException is thrown if the Tally object is not currently storing data points.

outputSummary

public void outputSummary(java.io.PrintStream out,
                          boolean withHeader)
Output the summary statistics that were collected for the WeightedTally.

Overrides:
outputSummary in class Tally
Parameters:
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.