vtf-logo

Algorithm: Statistics functions


Functions

template<typename InputIterator>
std::iterator_traits< InputIterator
>::value_type 
ads::computeMinimum (InputIterator beginning, InputIterator end)
 Compute the minimum value for the elements in the range.
template<typename InputIterator>
std::iterator_traits< InputIterator
>::value_type 
ads::computeMaximum (InputIterator beginning, InputIterator end)
 Compute the maximum value for the elements in the range.
template<typename InputIterator, typename T>
void ads::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 
ads::computeMean (InputIterator beginning, InputIterator end)
 Compute the mean value for the elements in the range.
template<typename InputIterator, typename T>
void ads::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 ads::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 
ads::computeVariance (ForwardIterator beginning, ForwardIterator end)
 Compute the variance for the elements in the range.
template<typename ForwardIterator, typename T>
void ads::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.

Function Documentation

template<typename ForwardIterator, typename T>
void ads::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.

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 ads::computeMeanAndVariance ( ForwardIterator  beginning,
ForwardIterator  end,
T *  mean,
T *  variance 
)

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.


Generated on Fri Aug 24 12:55:37 2007 for Algorithms and Data Structures Package by  doxygen 1.4.7