edu.ucsb.nmsl.tools
Class DataSetStatistic

java.lang.Object
  extended by edu.ucsb.nmsl.tools.BaseStatistic
      extended by edu.ucsb.nmsl.tools.DataSetStatistic
All Implemented Interfaces:
Statistic

public class DataSetStatistic
extends BaseStatistic

This class represents a statistic that represents a set of statistical information. Using a set of statistics allows for the calculation of an average, median, mode and standard deviation, all of which are not possible using the StatisticalPackage class.

The purpose of this class is to facilitate the research associated with the creation of the system and is not needed in the normal operation of AutoCap. Only the displayString method is overloaded withing the definition.

Version:
1.0

Field Summary
protected  java.util.LinkedList Data
          A linked list containing all the data in the data set.
protected  double Sum
          A running sum of all the data in the data set.
protected  double Var
          A running variance of all the data in the data set.
 
Fields inherited from class edu.ucsb.nmsl.tools.BaseStatistic
Name, Value
 
Constructor Summary
DataSetStatistic(java.lang.String name)
          This contructor builds a DataSetStatistic instance with the name specified by "name" with an empty data set.
DataSetStatistic(java.lang.String name, java.util.Collection c)
          This constructor creates a DataSetStatistic with a given name and with data from the specified collection.
 
Method Summary
 void addDataPoint(double x)
          This method adds a data point to the set.
 java.lang.String displayString()
          This method returns a string that can be used to neatly show the statistical information associated with this particular instance.
 double getMean()
          This method returns the mean of all data points in the set.
 double getMedian()
          This method calculates and returns the median value of the data points in the set.
 double getMode()
          This method returns the mode of all the data points in the set.
 double getStdDev()
          This method calculates are returns the standard deviation of all the data in the set.
static void main(java.lang.String[] args)
          This method is meant for testing purposes and is not call in the operation of AutoCap.
 void removeDataPoint(double x)
          This method removes a data point from the set.
 
Methods inherited from class edu.ucsb.nmsl.tools.BaseStatistic
equals, getName, getValue, setName, setValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Data

protected java.util.LinkedList Data
A linked list containing all the data in the data set.


Sum

protected double Sum
A running sum of all the data in the data set.


Var

protected double Var
A running variance of all the data in the data set.

Constructor Detail

DataSetStatistic

public DataSetStatistic(java.lang.String name,
                        java.util.Collection c)
This constructor creates a DataSetStatistic with a given name and with data from the specified collection.

Parameters:
name - The name associated with the instance.
c - A collection of data that becomes the data points in the data set.

DataSetStatistic

public DataSetStatistic(java.lang.String name)
This contructor builds a DataSetStatistic instance with the name specified by "name" with an empty data set.

Parameters:
name - The name of the DataSetStatisic.
Method Detail

addDataPoint

public void addDataPoint(double x)
This method adds a data point to the set. All data is entered as a double.

Parameters:
x - The data point to be added to the data set.

removeDataPoint

public void removeDataPoint(double x)
This method removes a data point from the set.

Parameters:
x - The value of the data point to be removed.

getStdDev

public double getStdDev()
This method calculates are returns the standard deviation of all the data in the set. The calculation is sped up by keeping a running sum and variance as data points are added and subtracted from the set.

Returns:
The standard deviation of all the data points in the set.

getMean

public double getMean()
This method returns the mean of all data points in the set. The calculation is sped up by using a running sum of all the data points as they are added to and subracted from the set.

Returns:
The mean of all data points in the set.

getMedian

public double getMedian()
This method calculates and returns the median value of the data points in the set. This is the straight forward linear implementation of the median algorithm. Perhaps in the future a faster median algorithm can be used.

Returns:
The median value of the data points in the set.

getMode

public double getMode()
This method returns the mode of all the data points in the set. There is no implementation yet as this functionality was not needed during the implemenation of AutoCap.

Returns:
0.0

displayString

public java.lang.String displayString()
This method returns a string that can be used to neatly show the statistical information associated with this particular instance. Each data point in the set is displayed on an individual line and the central tendencies are listed at the end.

Returns:
A string representing the statistical information. This string usually takes the form of <Name> = <Data Point1> ...;

main

public static void main(java.lang.String[] args)
This method is meant for testing purposes and is not call in the operation of AutoCap.