Project
Loading...
Searching...
No Matches
o2::tpc::RobustAverage Class Reference

#include <RobustAverage.h>

Public Member Functions

 RobustAverage (const unsigned int maxValues, bool withWeights=true)
 
 RobustAverage ()=default
 default constructor
 
 RobustAverage (std::vector< float > &&values)
 
void reserve (const unsigned int maxValues)
 
void clear ()
 clear the stored values
 
void addValue (const float value, const float weight=1)
 
std::pair< float, float > getFilteredAverage (const float sigma=3, const float interQuartileRange=0.9)
 
std::tuple< float, float, float, unsigned intfilterPointsMedian (const float maxAbsMedian, const float sigma=5)
 remove all the point which are abs(val - val_median)>maxAbsMedian
 
float getMean () const
 
float getTrunctedMean (float low, float high)
 
float getMedian ()
 
float getWeightedMean () const
 
float getStdDev ()
 
const auto & getValues () const
 
void setValues (const std::vector< float > &values)
 
const auto & getWeigths () const
 
void print () const
 values which will be averaged and filtered
 
void sort ()
 
bool getUseWeights () const
 returns if weights are stored
 
void setUseWeights (bool useweights)
 returns if weights are stored
 
float getQuantile (float quantile, int type)
 

Detailed Description

class to perform filtering of outliers and robust averaging of a set of values. This class is more or less a dummy for now... TODO add more sophisticated methods

Usage using existing data:

  1. std::vector<float> values{1., 2., 2.3};
  2. o2::tpc::RobustAverage rob(std::move(values));
  3. float average = rob.getFilteredAverage(3);

Usage using copy of data:

  1. o2::tpc::RobustAverage rob(3);
  2. rob.addValue(1.); rob.addValue(2.); rob.addValue(2.3);
  3. float average = rob.getFilteredAverage(3);

Definition at line 40 of file RobustAverage.h.

Constructor & Destructor Documentation

◆ RobustAverage() [1/3]

o2::tpc::RobustAverage::RobustAverage ( const unsigned int  maxValues,
bool  withWeights = true 
)
inline

constructor

Parameters
maxValuesmaximum number of values which will be averaged. Copy of values will be done.
withWeightsalso storing weights for weighted mean

Definition at line 46 of file RobustAverage.h.

◆ RobustAverage() [2/3]

o2::tpc::RobustAverage::RobustAverage ( )
default

default constructor

◆ RobustAverage() [3/3]

o2::tpc::RobustAverage::RobustAverage ( std::vector< float > &&  values)
inline

constructor

Parameters
valuesvalues which will be averaged and filtered. Move operator is used here!

Definition at line 59 of file RobustAverage.h.

Member Function Documentation

◆ addValue()

void o2::tpc::RobustAverage::addValue ( const float  value,
const float  weight = 1 
)
Parameters
valuevalue which will be added to the list of stored values for averaging
weightweight of the value (weight will only be stored if flag to weights is true)

Definition at line 193 of file RobustAverage.cxx.

◆ clear()

void o2::tpc::RobustAverage::clear ( )

clear the stored values

Definition at line 187 of file RobustAverage.cxx.

◆ filterPointsMedian()

std::tuple< float, float, float, unsigned int > o2::tpc::RobustAverage::filterPointsMedian ( const float  maxAbsMedian,
const float  sigma = 5 
)

remove all the point which are abs(val - val_median)>maxAbsMedian

Definition at line 57 of file RobustAverage.cxx.

◆ getFilteredAverage()

std::pair< float, float > o2::tpc::RobustAverage::getFilteredAverage ( const float  sigma = 3,
const float  interQuartileRange = 0.9 
)

returns the filtered average value

Parameters
sigmamaximum accepted standard deviation: sigma*stdev
interQuartileRangenumber of points in inner quartile to consider

Definition at line 22 of file RobustAverage.cxx.

◆ getMean()

float o2::tpc::RobustAverage::getMean ( ) const
inline
Returns
returns mean of stored values

Definition at line 81 of file RobustAverage.h.

◆ getMedian()

float o2::tpc::RobustAverage::getMedian ( )
Returns
returns the median

Definition at line 172 of file RobustAverage.cxx.

◆ getQuantile()

float o2::tpc::RobustAverage::getQuantile ( float  quantile,
int  type 
)
Returns
returns the quantile value - linear interpolation or median unbiased used -
Parameters
quantilequantile to get
typeinterpolation type: type=0 use linear interpolation, type=1 use unbiased median (in case of low statistics)

Definition at line 236 of file RobustAverage.cxx.

◆ getStdDev()

float o2::tpc::RobustAverage::getStdDev ( )
inline
Returns
returns standard deviation of stored values

Definition at line 95 of file RobustAverage.h.

◆ getTrunctedMean()

float o2::tpc::RobustAverage::getTrunctedMean ( float  low,
float  high 
)

returns truncated mean for range min and max

Parameters
lowlower fraction rejection e.g. 0.05 -> lower 5% are rejected
highupper fraction rejection e.g. 0.95 -> upper 5% are rejected

Definition at line 201 of file RobustAverage.cxx.

◆ getUseWeights()

bool o2::tpc::RobustAverage::getUseWeights ( ) const
inline

returns if weights are stored

Definition at line 112 of file RobustAverage.h.

◆ getValues()

const auto & o2::tpc::RobustAverage::getValues ( ) const
inline
Returns
returns stored values

Definition at line 98 of file RobustAverage.h.

◆ getWeightedMean()

float o2::tpc::RobustAverage::getWeightedMean ( ) const
inline
Returns
returns weighted mean of stored values

Definition at line 92 of file RobustAverage.h.

◆ getWeigths()

const auto & o2::tpc::RobustAverage::getWeigths ( ) const
inline
Returns
returns stored values

Definition at line 103 of file RobustAverage.h.

◆ print()

void o2::tpc::RobustAverage::print ( ) const

values which will be averaged and filtered

Definition at line 159 of file RobustAverage.cxx.

◆ reserve()

void o2::tpc::RobustAverage::reserve ( const unsigned int  maxValues)

reserve memory for member

Parameters
maxValuesmaximum number of values which will be averaged. Copy of values will be done.

Definition at line 16 of file RobustAverage.cxx.

◆ setUseWeights()

void o2::tpc::RobustAverage::setUseWeights ( bool  useweights)
inline

returns if weights are stored

Definition at line 115 of file RobustAverage.h.

◆ setValues()

void o2::tpc::RobustAverage::setValues ( const std::vector< float > &  values)
inline

Definition at line 100 of file RobustAverage.h.

◆ sort()

void o2::tpc::RobustAverage::sort ( )

Definition at line 108 of file RobustAverage.cxx.


The documentation for this class was generated from the following files: