VR-Forces 4.3 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Member Functions | Protected Member Functions | Private Attributes
DtAverager Class Reference

class DtAverager: More...

Public Member Functions

 DtAverager ()
 Default constructor; assumes a maximum population of 100 samples.
 DtAverager (unsigned int maxPopulation)
 DtAverager (const DtAverager &orig)
 copy constructor
DtAverageroperator= (const DtAverager &orig)
 assignment operator
virtual ~DtAverager ()
 destructor
virtual double sampleMean () const
 Compute (if needed) and retrieve the sum of the samples divided by the current population size.
virtual double sampleMedian () const
 Compute (if needed) by sorting samples and finding the middle value (or average of two middle values for an even population.
virtual double sampleStandardDeviation () const
 Compute (if needed) the sample standard deviation.
virtual double sampleMinimum () const
 Find (if needed) the sample maximum; note that this is found as a side effect of sampleMedian(), so if both are desired, call that first.
virtual double sampleMaximum () const
 Find (if needed) the sample minumum; note that this is found as a side effect of sampleMedian(), so if both are desired, call that first.
virtual void addSample (double sample)
 Add a sample to the population. This calls invalidateStatistics().
virtual double lastSample () const
virtual unsigned int maxPopulationSize () const
 Retrieve the maximum population size.
virtual void setMaxPopulationSize (unsigned int maxPopulation)
 Set the maximum population size. This invalidates the current population.
virtual void invalidatePopulation ()
 Clear all existing samples.
virtual std::vector< double > & samples ()
 A pointer to the array of samples.
virtual const std::vector
< double > & 
samples () const
virtual unsigned int currentSampleIndex () const
 Index which points to the most recent sample in the array.
virtual unsigned int currentPopulationSize () const
 Current population size.

Protected Member Functions

virtual void invalidateStatistics ()
 Mark all cached statistics as invalid, forcing them to be recomputed the next time they are accessed.
virtual void validateStatistics ()
 Reset all the cached flags as true.
void resetStatistics ()

Private Attributes

double mySampleMean
bool mySampleMeanValid
double mySampleMedian
bool mySampleMedianValid
double mySampleStandardDeviation
bool mySampleStandardDeviationValid
double mySampleMaximum
bool mySampleMaximumValid
double mySampleMinimum
bool mySampleMinimumValid
unsigned int myCurrentPopulationSize
unsigned int myCurrentSampleIndex
std::vector< double > mySamples
std::vector< double > mySortedSamples

Detailed Description

class DtAverager:

DtAverager maintains a cyclical population of the N most recent samples and can, on command, compute the mean, median, standard deviation, minimum and maximum values of the population. N may be changed, and all samples may be invalidated to restart the process.

Constructor & Destructor Documentation

DtAverager::DtAverager ( )

Default constructor; assumes a maximum population of 100 samples.

DtAverager::DtAverager ( unsigned int  maxPopulation)
DtAverager::DtAverager ( const DtAverager orig)

copy constructor

virtual DtAverager::~DtAverager ( )
virtual

destructor

Member Function Documentation

DtAverager& DtAverager::operator= ( const DtAverager orig)

assignment operator

virtual double DtAverager::sampleMean ( ) const
virtual

Compute (if needed) and retrieve the sum of the samples divided by the current population size.

Returns
0.0 if the the current population size is 0. Else returns the mean of all the current samples.
virtual double DtAverager::sampleMedian ( ) const
virtual

Compute (if needed) by sorting samples and finding the middle value (or average of two middle values for an even population.

Returns
0.0 if the the current population size is 0. Else returns the median of all the current samples.
virtual double DtAverager::sampleStandardDeviation ( ) const
virtual

Compute (if needed) the sample standard deviation.

Returns
The standard deviation of the current samples, or 0.0 if the the current population size is less than 2.
virtual double DtAverager::sampleMinimum ( ) const
virtual

Find (if needed) the sample maximum; note that this is found as a side effect of sampleMedian(), so if both are desired, call that first.

Returns
The minimum of the current samples, or 0.0 if the the current population size is 0.
virtual double DtAverager::sampleMaximum ( ) const
virtual

Find (if needed) the sample minumum; note that this is found as a side effect of sampleMedian(), so if both are desired, call that first.

Returns
The maximum of the current samples, or 0.0 if the the current population size is 0.
virtual void DtAverager::addSample ( double  sample)
virtual

Add a sample to the population. This calls invalidateStatistics().

virtual double DtAverager::lastSample ( ) const
virtual
Returns
The last sample added to the population, or -1 if no samples have been added yet.
virtual unsigned int DtAverager::maxPopulationSize ( ) const
virtual

Retrieve the maximum population size.

Once the population reaches this size, old samples are removed as new ones are added.

virtual void DtAverager::setMaxPopulationSize ( unsigned int  maxPopulation)
virtual

Set the maximum population size. This invalidates the current population.

virtual void DtAverager::invalidatePopulation ( )
virtual

Clear all existing samples.

virtual std::vector<double>& DtAverager::samples ( )
virtual

A pointer to the array of samples.

virtual const std::vector<double>& DtAverager::samples ( ) const
virtual
virtual unsigned int DtAverager::currentSampleIndex ( ) const
virtual

Index which points to the most recent sample in the array.

virtual unsigned int DtAverager::currentPopulationSize ( ) const
virtual

Current population size.

virtual void DtAverager::invalidateStatistics ( )
protectedvirtual

Mark all cached statistics as invalid, forcing them to be recomputed the next time they are accessed.

virtual void DtAverager::validateStatistics ( )
protectedvirtual

Reset all the cached flags as true.

void DtAverager::resetStatistics ( )
protected

Member Data Documentation

double DtAverager::mySampleMean
mutableprivate
bool DtAverager::mySampleMeanValid
mutableprivate
double DtAverager::mySampleMedian
mutableprivate
bool DtAverager::mySampleMedianValid
mutableprivate
double DtAverager::mySampleStandardDeviation
mutableprivate
bool DtAverager::mySampleStandardDeviationValid
mutableprivate
double DtAverager::mySampleMaximum
mutableprivate
bool DtAverager::mySampleMaximumValid
mutableprivate
double DtAverager::mySampleMinimum
mutableprivate
bool DtAverager::mySampleMinimumValid
mutableprivate
unsigned int DtAverager::myCurrentPopulationSize
private
unsigned int DtAverager::myCurrentSampleIndex
private
std::vector<double> DtAverager::mySamples
mutableprivate
std::vector<double> DtAverager::mySortedSamples
mutableprivate

The documentation for this class was generated from the following file:

Document ID: Generated on Wed Mar 11 21:20:57 EDT 2015 from SVN revision 150940
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)