Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes

Stats::RunCalc< T > Class Template Reference

calculates mean, min, max, etc. as running values. More...

List of all members.

Public Member Functions

 RunCalc (const RunCalcSetup &s)
void clear ()
const RunCalcSetupsetup () 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
mostFreq () const
sum () const
min (int *index_of_min=0) const
max (int *index_of_max=0) const
extreme (int *index_of_extr=0) const
median (int *index_of_median=0) const
sqSum () const
double rms () const
double stdDev () const
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_
minval_
maxval_
sum_x
sum_xx
sum_w
sum_wx
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

template<class T>
Stats::RunCalc< T >::RunCalc ( const RunCalcSetup s  )  [inline]

Member Function Documentation

template<class T >
bool Stats::RunCalc< T >::addExceptMed ( val,
wt 
) [inline, protected]
template<class T >
RunCalc< T > & Stats::RunCalc< T >::addValue ( data,
weight = 1 
) [inline]
template<class T >
RunCalc< T > & Stats::RunCalc< T >::addValues ( int  sz,
const T *  data,
const T *  weights = 0 
) [inline]
template<class T >
double Stats::RunCalc< T >::average (  )  const [inline]
template<class T >
void Stats::RunCalc< T >::clear (  )  [inline]
template<class T >
T Stats::RunCalc< T >::clipVal ( float  ratio,
bool  upper 
) const [inline]

require median; 0 <= ratio <= 1

template<class T>
int Stats::RunCalc< T >::count (  )  const [inline]
template<class T >
T Stats::RunCalc< T >::extreme ( int *  index_of_extr = 0  )  const [inline]
template<class T >
bool Stats::RunCalc< T >::findMedIdx ( val  )  const [inline, protected]
template<class T >
int Stats::RunCalc< T >::getIndex ( Type  t  )  const [inline]

only for Median, Min and Max

template<class T >
double Stats::RunCalc< T >::getValue ( Stats::Type  t  )  const [inline]
template<class T>
bool Stats::RunCalc< T >::hasUndefs (  )  const [inline]
template<class T>
bool Stats::RunCalc< T >::isEmpty (  )  const [inline]
template<class T>
bool Stats::RunCalc< T >::isWeighted (  )  const [inline]
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 >::max ( int *  index_of_max = 0  )  const [inline]
template<class T >
T Stats::RunCalc< T >::median ( int *  index_of_median = 0  )  const [inline]
template<class T >
T Stats::RunCalc< T >::min ( int *  index_of_min = 0  )  const [inline]
template<class T >
T Stats::RunCalc< T >::mostFreq (  )  const [inline]
template<class T >
double Stats::RunCalc< T >::normvariance (  )  const [inline]
template<class T>
RunCalc<T>& Stats::RunCalc< T >::operator+= ( t  )  [inline]
template<class T >
bool Stats::RunCalc< T >::remExceptMed ( val,
wt 
) [inline, protected]
template<class T >
RunCalc< T > & Stats::RunCalc< T >::removeValue ( data,
weight = 1 
) [inline]
template<class T >
RunCalc< T > & Stats::RunCalc< T >::replaceValue ( olddata,
newdata,
wt = 1 
) [inline]
template<class T >
double Stats::RunCalc< T >::rms (  )  const [inline]
template<class T>
const RunCalcSetup& Stats::RunCalc< T >::setup (  )  const [inline]
template<class T>
int Stats::RunCalc< T >::size ( bool  used = true  )  const [inline]
template<class T >
T Stats::RunCalc< T >::sqSum (  )  const [inline]
template<class T >
double Stats::RunCalc< T >::stdDev (  )  const [inline]
template<class T >
T Stats::RunCalc< T >::sum (  )  const [inline]
template<class T >
double Stats::RunCalc< T >::variance (  )  const [inline]

Member Data Documentation

template<class T>
TypeSet<int> Stats::RunCalc< T >::clss_ [protected]
template<class T>
TypeSet<T> Stats::RunCalc< T >::clsswt_ [protected]
template<class T>
int Stats::RunCalc< T >::curmedidx_ [mutable, protected]
template<class T>
int Stats::RunCalc< T >::maxidx_ [protected]
template<class T>
T Stats::RunCalc< T >::maxval_ [protected]
template<class T>
int Stats::RunCalc< T >::minidx_ [protected]
template<class T>
T Stats::RunCalc< T >::minval_ [protected]
template<class T>
int Stats::RunCalc< T >::nradded_ [protected]
template<class T>
int Stats::RunCalc< T >::nrused_ [protected]
template<class T>
RunCalcSetup Stats::RunCalc< T >::setup_ [protected]
template<class T>
T Stats::RunCalc< T >::sum_w [protected]
template<class T>
T Stats::RunCalc< T >::sum_wx [protected]
template<class T>
T Stats::RunCalc< T >::sum_wxx [protected]
template<class T>
T Stats::RunCalc< T >::sum_x [protected]
template<class T>
T Stats::RunCalc< T >::sum_xx [protected]
template<class T>
TypeSet<T> Stats::RunCalc< T >::vals_