Main Page   Namespace List   Compound List   File List   Compound Members   File Members  

Statistics Class Reference

The Statistics class computes simple statistical quantities from a double array of samples provided by the user. This rest of this file contains the definition of the class Statistics. It contains the declarations of the member functions and data members of the class. However it does not include initialization of the data. That must be done in the class constructor. More...

#include <Statistics.hh>

List of all members.

Public Methods

 Statistics (int arrayLengthIn, double *arrayIn)
 The class constructor. More...

 ~Statistics ()
 The class destructor. More...

double GetMinimum ()
 Returns the mimimum value of the samples.

double GetMaximum ()
double GetMean ()
double GetStdDev ()
double GetVariance ()
double GetMedian ()

Private Methods

void ComputeMinimum (void)
 Computes the mimimum value of the samples.

void ComputeMaximum (void)
void ComputeMean (void)
void ComputeMeanOfSquares (void)
void ComputeVariance (void)
void ComputeMedian (void)
void SelectionSort (void)
 Used in calculation of median.

int MaximumIndex (int SubLength)
 Used in calculation of median.


Private Attributes

int arrayLength
 The number of samples.

double* array
 Array to store values of samples. Must be initialized by user in application code.

double* sortedArray
 Used in calculation of median.

double minimum
 Variable which holds the minimum value of the samples.

double maximum
double mean
double meanOfSquares
double standardDeviation
double variance
double median


Detailed Description

The Statistics class computes simple statistical quantities from a double array of samples provided by the user. This rest of this file contains the definition of the class Statistics. It contains the declarations of the member functions and data members of the class. However it does not include initialization of the data. That must be done in the class constructor.


Constructor & Destructor Documentation

Statistics::Statistics ( int arrayLengthIn,
double * arrayIn )
 

The class constructor.

General facts about constructors:

  1. The constructor initializes (all) the data members of the class.
  2. It must have the same name as the class.
  3. A class can have more than one constructor, but the input parameters of two different constructors must be different
  4. A constructor does not have a return type
  5. The constructor must always be a public method!
  6. The constructor can (and often does) call other member functions
  7. In an application program you create a new instance of a class by calling one of the class's constructors.
  8. Each separate instance of the class is called an object.
The input parameters to the Statistics class are
Parameters:
arrayLengthIn:   The length of the array which stores the samples
arrayIn:   The array in which the samples are stored

The constructor uses the input parameters to initialize

the private data members Statistics::arrayLength and Statistics::array

Then it calls other member functions to compute the values of the private data members

  1. Statistics::minimum
  2. Statistics::maximum
  3. Statistics::mean
  4. Statistics::variance
  5. Statistics::standardDeviation
  6. Statistics::median
Question: What is wrong with the declaration

Statistics(int arrayLength, double *array);

Statistics::~Statistics ( )
 

The class destructor.

General facts about destructors:

  1. The destructor is called when an object is destroyed
  2. The destructor is always named ~ClassName().
  3. It has no parameter list or return type
  4. The destructor of an object is called automatically when the program that is executing leaves the scope in which the object was created
  5. The most common use of a destructor is to delete memory that was dynamically allocated by the constructor.
  6. In OCS the destructor ~RanNumGen() saves the current state of the RNG to a file.
The Statistics destructor deletes the array Statistics::sortedArray


Member Function Documentation

void Statistics::ComputeMaximum ( void ) [private]
 

void Statistics::ComputeMean ( void ) [private]
 

void Statistics::ComputeMeanOfSquares ( void ) [private]
 

void Statistics::ComputeMedian ( void ) [private]
 

void Statistics::ComputeMinimum ( void ) [private]
 

Computes the mimimum value of the samples.

void Statistics::ComputeVariance ( void ) [private]
 

double Statistics::GetMaximum ( ) [inline]
 

double Statistics::GetMean ( ) [inline]
 

double Statistics::GetMedian ( ) [inline]
 

double Statistics::GetMinimum ( ) [inline]
 

Returns the mimimum value of the samples.

double Statistics::GetStdDev ( ) [inline]
 

double Statistics::GetVariance ( ) [inline]
 

int Statistics::MaximumIndex ( int SubLength ) [private]
 

Used in calculation of median.

void Statistics::SelectionSort ( void ) [private]
 

Used in calculation of median.


Member Data Documentation

double * Statistics::array [private]
 

Array to store values of samples. Must be initialized by user in application code.

int Statistics::arrayLength [private]
 

The number of samples.

double Statistics::maximum [private]
 

double Statistics::mean [private]
 

double Statistics::meanOfSquares [private]
 

double Statistics::median [private]
 

double Statistics::minimum [private]
 

Variable which holds the minimum value of the samples.

double * Statistics::sortedArray [private]
 

Used in calculation of median.

double Statistics::standardDeviation [private]
 

double Statistics::variance [private]
 


The documentation for this class was generated from the following files:
Generated at Fri Feb 21 10:29:46 2003 for hello by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000