Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://www.atnf.csiro.au/computing/software/casacore/casacore-1.2.0/doc/html/classcasa_1_1StatAcc.html
Дата изменения: Unknown Дата индексирования: Mon Feb 14 20:55:25 2011 Кодировка: Поисковые слова: annular solar eclipse |
A statistics accumulator. More...
#include <StatAcc.h>
Public Member Functions | |
StatAcc () | |
constructors and destructor. | |
StatAcc (const StatAcc &) | |
~StatAcc () | |
void | reset () |
Reset or copy the accumulator attributes. | |
void | copy (const StatAcc &) |
StatAcc & | operator= (const StatAcc &) |
Operators for adding and copying accumulators. | |
StatAcc | operator+ (const StatAcc &) |
StatAcc & | operator+= (const StatAcc &) |
void | put (const T v) |
Accumulate input value(s) v with weight w. | |
void | put (const T v, const Float w) |
void | put (const Array< T > &v) |
void | put (const Array< T > &v, const Array< Float > &w) |
void | put (const Block< T > &v) |
void | put (const Block< T > &v, const Block< Float > &w) |
Double | getWtot () const |
Get statistics results one at a time. | |
uInt | getCount () const |
Fallible< Double > | getMin () const |
Fallible< Double > | getMax () const |
Fallible< Double > | getMean () const |
Fallible< Double > | getRms () const |
Fallible< Double > | getVariance () const |
Fallible< Double > | getRmsAbs () const |
void | printSummaryList (std::ostream &, const String &caption) const |
Print summary of accumulated statistics. | |
void | printSummaryLine (std::ostream &, const String &caption) const |
void | printSummaryLineHeader (std::ostream &, const String &caption) const |
Private Member Functions | |
void | put1 (const T, const Float) |
Accumulate a single weighted value. | |
Private Attributes | |
Double | itsWtot |
Double | itsWsum |
Double | itsWssum |
Double | itsMin |
Double | itsMax |
uInt | itsCount |
A statistics accumulator.
StatAcc stands for `Statistics Accumulator'.
A statistics accumulator accepts (weighted) input values and calculates simple statistice (min, max, weighted mean, rms etc). The accepted input types are real, i.e. Int, uInt, Float, Double, but not Complex. The reason for this is that the < operator of Complex (needed for min/max) works on the norm in any case, and the sqrt function (needed for rms) yields an ambiguous result.
Restriction to real types also allows the internal arithmetic type to be Double rather than the input type. The latter would give all kinds of complications with weighting, accuracy and overflow if the input type would be Int or uInt.
The (weighted) values are fed to StatAcc via the member function `put'. They can be fed individually, or in the form of an Array. The weights are optional (default = 1) and always have type Float.
Asking for a result does not change the internal state. The type of the returned results is always Fallible<Double>. A result is invalid if no input values with non-zero weight have been accumulated yet.
The accumulator can be re-initialised with the function `reset'. Accumulators can be added to each other, which is as if their combined values had been accumulated in the same accumulator.
Some functions have been provided to display a summary of the statistics results. One may choose between a one-line format (with an optional associated header line), and a list.
StatAcc<T> s; // T is Float, Double, Int etc Matrix<T> vv(2,5); // a matrix (array) of input values Matrix<Float> wgt(2,5); // an associated matrix of weights .... fill vv and wgt with values and individual weights ..\. s.put(vv,wgt); // accumulate the weighted values Fallible<Double> min = s.getMin(); // return the minimum value s.reset(); // re-initialise s.put(vv); // if wgt omitted, default = 1.0 if (s.getRms().isValid() { // check validity of rms ... use it ..\. }
One often needs simple statistics of a series of values, which may occur by themselves or in arrays at various points in a program. Sincs it is a pain to have to assign accumulation variables, and to write statistics evaluation code (including exceptions), this helper class is provided.
Definition at line 125 of file StatAcc.h.
casa::StatAcc< T >::StatAcc | ( | ) |
constructors and destructor.
casa::StatAcc< T >::StatAcc | ( | const StatAcc< T > & | ) |
casa::StatAcc< T >::~StatAcc | ( | ) | [inline] |
void casa::StatAcc< T >::copy | ( | const StatAcc< T > & | ) |
uInt casa::StatAcc< T >::getCount | ( | ) | const |
Fallible<Double> casa::StatAcc< T >::getMax | ( | ) | const |
Fallible<Double> casa::StatAcc< T >::getMean | ( | ) | const |
Fallible<Double> casa::StatAcc< T >::getMin | ( | ) | const |
Fallible<Double> casa::StatAcc< T >::getRms | ( | ) | const |
Fallible<Double> casa::StatAcc< T >::getRmsAbs | ( | ) | const |
Fallible<Double> casa::StatAcc< T >::getVariance | ( | ) | const |
Double casa::StatAcc< T >::getWtot | ( | ) | const |
Get statistics results one at a time.
Count is the nr of values accumulated. Wtot is the sum of the weights. Rms is defined w.r.t. the mean, and is the square of Variance. RmsAbs is the root-mean-square of the absolute input values.
StatAcc casa::StatAcc< T >::operator+ | ( | const StatAcc< T > & | ) |
StatAcc& casa::StatAcc< T >::operator+= | ( | const StatAcc< T > & | ) |
StatAcc& casa::StatAcc< T >::operator= | ( | const StatAcc< T > & | ) |
Operators for adding and copying accumulators.
void casa::StatAcc< T >::printSummaryLine | ( | std::ostream & | , | |
const String & | caption | |||
) | const |
void casa::StatAcc< T >::printSummaryLineHeader | ( | std::ostream & | , | |
const String & | caption | |||
) | const |
void casa::StatAcc< T >::printSummaryList | ( | std::ostream & | , | |
const String & | caption | |||
) | const |
Print summary of accumulated statistics.
Line is a one-line summary, including the (short) caption. LineHeader gives a one-line explanation of the numbers. List uses a separate line for each result (mean, max etc).
void casa::StatAcc< T >::put | ( | const Array< T > & | v, | |
const Array< Float > & | w | |||
) |
void casa::StatAcc< T >::put | ( | const Array< T > & | v | ) |
void casa::StatAcc< T >::put | ( | const Block< T > & | v, | |
const Block< Float > & | w | |||
) |
void casa::StatAcc< T >::put | ( | const T | v | ) | [inline] |
Accumulate input value(s) v with weight w.
If weight is omitted, the default=1.
Definition at line 205 of file StatAcc.h.
References casa::StatAcc< T >::put1().
void casa::StatAcc< T >::put | ( | const T | v, | |
const Float | w | |||
) | [inline] |
Definition at line 210 of file StatAcc.h.
References casa::StatAcc< T >::put1().
void casa::StatAcc< T >::put | ( | const Block< T > & | v | ) |
void casa::StatAcc< T >::put1 | ( | const | T, | |
const | Float | |||
) | [private] |
Accumulate a single weighted value.
Referenced by casa::StatAcc< T >::put().
void casa::StatAcc< T >::reset | ( | ) |
Reset or copy the accumulator attributes.
uInt casa::StatAcc< T >::itsCount [private] |
Double casa::StatAcc< T >::itsMax [private] |
Double casa::StatAcc< T >::itsMin [private] |
Double casa::StatAcc< T >::itsWssum [private] |
Double casa::StatAcc< T >::itsWsum [private] |
Double casa::StatAcc< T >::itsWtot [private] |