calculates mean, min, max, etc. as running values.
More...
List of all members.
Public Member Functions |
| | RunCalc (const RunCalcSetup &s) |
| void | clear () |
| const RunCalcSetup & | setup () const |
| bool | isWeighted () const |
| RunCalc< T > & | addValue (T data, T weight=1) |
| RunCalc< T > & | addValues (int sz, const T *data, const T *weights=0) |
| RunCalc< T > & | replaceValue (T olddata, T newdata, T wt=1) |
| RunCalc< T > & | removeValue (T data, T weight=1) |
| double | getValue (Type) const |
| int | getIndex (Type) const |
| | only for Median, Min and Max
|
| RunCalc< T > & | operator+= (T t) |
| bool | hasUndefs () const |
| int | size (bool used=true) const |
| bool | isEmpty () const |
| int | count () const |
| double | average () const |
| double | variance () const |
| double | normvariance () const |
| T | mostFreq () const |
| T | sum () const |
| T | min (int *index_of_min=0) const |
| T | max (int *index_of_max=0) const |
| T | extreme (int *index_of_extr=0) const |
| T | median (int *index_of_median=0) const |
| T | sqSum () const |
| double | rms () const |
| double | stdDev () const |
| T | clipVal (float ratio, bool upper) const |
| | require median; 0 <= ratio <= 1
|
Public Attributes |
| TypeSet< T > | vals_ |
Protected Member Functions |
| bool | isZero (const T &t) const |
| bool | findMedIdx (T) const |
| bool | addExceptMed (T, T) |
| bool | remExceptMed (T, T) |
| template<> |
| bool | isZero (const float &val) const |
| template<> |
| bool | isZero (const double &val) const |
Protected Attributes |
| RunCalcSetup | setup_ |
| int | nradded_ |
| int | nrused_ |
| int | minidx_ |
| int | maxidx_ |
| T | minval_ |
| T | maxval_ |
| T | sum_x |
| T | sum_xx |
| T | sum_w |
| T | sum_wx |
| T | sum_wxx |
| TypeSet< int > | clss_ |
| TypeSet< T > | clsswt_ |
| int | curmedidx_ |
Detailed Description
template<class T>
class Stats::RunCalc< T >
calculates mean, min, max, etc. as running values.
The idea is that you simply add values and ask for a stat whenever needed. The clear() method resets the object and makes it able to work with new data.
Adding values can be doing with weight (addValue) or without (operator +=). You can remove a value; for Min or Max this has no effect as this would require buffering all data.
The mostFrequent assumes the data contains integer classes. Then the class that is found most often will be the output. Weighting, again, assumes integer values. Beware that if you pass data that is not really class-data, the memory consumption can become large (and the result will be rather uninteresting).
The variance won't take the decreasing degrees of freedom into consideration when weights are provided.
The object is ready to use with int, float and double types. If other types are needed, you may need to specialise an isZero function for each new type.
Constructor & Destructor Documentation
Member Function Documentation
template<class T >
| bool Stats::RunCalc< T >::addExceptMed |
( |
T |
val, |
|
|
T |
wt | |
|
) |
| | [inline, protected] |
template<class T >
| T Stats::RunCalc< T >::clipVal |
( |
float |
ratio, |
|
|
bool |
upper | |
|
) |
| | const [inline] |
require median; 0 <= ratio <= 1
template<class T >
| T Stats::RunCalc< T >::extreme |
( |
int * |
index_of_extr = 0 |
) |
const [inline] |
template<class T >
| bool Stats::RunCalc< T >::findMedIdx |
( |
T |
val |
) |
const [inline, protected] |
only for Median, Min and Max
template<>
| bool Stats::RunCalc< float >::isZero |
( |
const float & |
val |
) |
const [inline, protected] |
template<>
| bool Stats::RunCalc< double >::isZero |
( |
const double & |
val |
) |
const [inline, protected] |
template<class T>
| bool Stats::RunCalc< T >::isZero |
( |
const T & |
t |
) |
const [inline, protected] |
template<class T >
| T Stats::RunCalc< T >::median |
( |
int * |
index_of_median = 0 |
) |
const [inline] |
template<class T >
| bool Stats::RunCalc< T >::remExceptMed |
( |
T |
val, |
|
|
T |
wt | |
|
) |
| | [inline, protected] |
Member Data Documentation