# SimpleStatistic Class Reference

Implements a class for summary statistics. More...

List of all members.

## Public Member Functions

SimpleStatistic (void)
template<class T>
SimpleStatistic (std::vector< T > &x)
double Mean (void) const
double Variance (void) const
double StdDev (void) const
void Clear (void)

## Detailed Description

Implements a class for summary statistics.

The SimpleStatistic class allows easy calculation of simple summary statistics. Unlike Statistic, it cannot be applied to ratio data. In addition to adding single values, with Add(), an entire vector of values can be added in the constructor.

Example:

``` SimpleStatistic stat;
double mean   = stat.Mean();   // mean = 3.000
double variance  = stat.Variance(); // variance = 2.500
double stddev  = stat.StdDev();  // stddev = 1.581
stat.Clear();  // clears internal data for new calculation

vector<double> x(5);
for (int i = 0; i < 5; ++i) {
x[i] = i;
}
SimpleStatistic vecStat(x);
double mean   = stat.Mean();   // mean = 3.000
double variance  = stat.Variance(); // variance = 2.500
double stddev  = stat.StdDev();  // stddev = 1.581
```

Definition at line 178 of file statistics.h.

## Constructor & Destructor Documentation

 SimpleStatistic::SimpleStatistic ( void )

Default constructor.

The default constructor simply initializes the internal data. After initializaiton, data is added with Add().

Definition at line 250 of file statistics.cpp.

template<class T>
 SimpleStatistic::SimpleStatistic ( std::vector< T > & x ) ` [inline]`

Constructor -- initialize with a vector.

May be used with any vector having an iterator that can produce a double. This may be a simple vector<double> (or any other vector whose elements can be converted to double by default conversions, but it could also be a vector<T>, where a method in T is called before this constructor to provide an implementation of operator* that returns an appropriate member from T (one that can be converted via default conversions to a double).

Parameters:
 x The vector to use in calculations

Definition at line 195 of file statistics.h.

## Member Function Documentation

 void SimpleStatistic::Add ( double x )

Add a double value to the statistic.

Parameters:

Definition at line 259 of file statistics.cpp.

Referenced by Model::percent(), and Model::Record().

 double SimpleStatistic::Mean ( void ) const

Returns mean of the data.

Definition at line 268 of file statistics.cpp.

Referenced by Model::percent(), Model::ReportDic(), and Model::Summarize().

 double SimpleStatistic::Variance ( void ) const

Returns variance of the data.

Definition at line 275 of file statistics.cpp.

Referenced by Model::ReportDic(), and StdDev().

 double SimpleStatistic::StdDev ( void ) const

Returns standard deviation of the data.

Definition at line 282 of file statistics.cpp.

References Variance().

Referenced by Model::Summarize().

 void SimpleStatistic::Clear ( void )

Re-initializes internal data for new calculations.

Definition at line 289 of file statistics.cpp.

The documentation for this class was generated from the following files:
Generated on Tue Mar 27 16:03:51 2007 for mcmc by  1.5.1