Algorithm: Statistics functions

Functions

template<typename InputIterator >
std::iterator_traits
< InputIterator >::value_type 
computeMinimum (InputIterator beginning, InputIterator end)
 Compute the minimum value for the elements in the range.
template<typename InputIterator >
std::iterator_traits
< InputIterator >::value_type 
computeMaximum (InputIterator beginning, InputIterator end)
 Compute the maximum value for the elements in the range.
template<typename InputIterator , typename T >
void computeMinimumAndMaximum (InputIterator beginning, InputIterator end, T *minimum, T *maximum)
 Compute the minimum and maximum values for the elements in the range.
template<typename InputIterator >
std::iterator_traits
< InputIterator >::value_type 
computeMean (InputIterator beginning, InputIterator end)
 Compute the mean value for the elements in the range.
template<typename InputIterator , typename T >
void computeMinimumMaximumAndMean (InputIterator beginning, InputIterator end, T *minimum, T *maximum, T *mean)
 Compute the minimum, maximum, and mean for the elements in the range.
template<typename ForwardIterator , typename T >
void computeMeanAndVariance (ForwardIterator beginning, ForwardIterator end, T *mean, T *variance)
 Compute the mean and variance for the elements in the range.
template<typename ForwardIterator >
std::iterator_traits
< ForwardIterator >
::value_type 
computeVariance (ForwardIterator beginning, ForwardIterator end)
 Compute the variance for the elements in the range.
template<typename ForwardIterator , typename T >
void computeMeanAbsoluteDeviationVarianceSkewAndCurtosis (ForwardIterator beginning, ForwardIterator end, T *mean, T *absoluteDeviation, T *variance, T *skew, T *curtosis)
 Compute the mean, absolute deviation, variance, skew and curtosis for the elements in the range.

Detailed Description


Function Documentation

template<typename ForwardIterator , typename T >
void computeMeanAbsoluteDeviationVarianceSkewAndCurtosis ( ForwardIterator  beginning,
ForwardIterator  end,
T *  mean,
T *  absoluteDeviation,
T *  variance,
T *  skew,
T *  curtosis 
) [inline]

Compute the mean, absolute deviation, variance, skew and curtosis for the elements in the range.

To compute the variance, I use the corrected two-pass algorithm presented in "Numerical Recipes."

\[ \mathrm{variance}(x) = \frac{1}{N - 1} \left( \sum_{j = 0}^{N - 1} (x_j - \bar{x})^2 - \frac{1}{N} \left( \sum_{j = 0}^{N - 1} (x_j - \bar{x}) \right)^2 \right) \]

Note that with exact arithmetic, the second sum is zero. With finite precision arithmetic, the term reduces the round-off error. The mean absolute deviation, skew, and curtosis are defined below.

\[ \mathrm{absoluteDeviation}(x) = \frac{1}{N} \sum_{j = 0}^{N - 1} |x_j - \bar{x}| \]

\[ \mathrm{skew}(x) = \frac{1}{N \sigma^3} \sum_{j = 0}^{N - 1} (x_j - \bar{x})^3 \]

\[ \mathrm{curtosis}(x) = \left( \frac{1}{N \sigma^4} \sum_{j = 0}^{N - 1} (x_j - \bar{x})^4 \right) - 3 \]

Note that the skew and curtosis are not defined when the variance is zero. in this case, the function prints a warning.

template<typename ForwardIterator , typename T >
void computeMeanAndVariance ( ForwardIterator  beginning,
ForwardIterator  end,
T *  mean,
T *  variance 
) [inline]

Compute the mean and variance for the elements in the range.

To compute the variance, I use the corrected two-pass algorithm presented in "Numerical Recipes."

\[ \mathrm{var}(x) = \frac{1}{N - 1} \left( \sum_{j = 0}^{N - 1} (x_j - \bar{x})^2 - \frac{1}{N} \left( \sum_{j = 0}^{N - 1} (x_j - \bar{x}) \right)^2 \right) \]

Note that with exact arithmetic, the second sum is zero. With finite precision arithmetic, the term reduces the round-off error. CONTINUE.

Referenced by computeVariance().

Generated on Thu Jun 30 02:14:51 2016 for Algorithms and Data Structures Package by  doxygen 1.6.3