Peano
Loading...
Searching...
No Matches
tarch::timing::GlidingAverageMeasurement Class Reference

GlidingAverageMeasurement. More...

#include <GlidingAverageMeasurement.h>

Collaboration diagram for tarch::timing::GlidingAverageMeasurement:

Public Member Functions

 GlidingAverageMeasurement (double weight=DefaultWeight, int maxEntries=16)
 Construct a measurement with a gliding measurement.
 
 ~GlidingAverageMeasurement ()=default
 
double getValue () const
 Return the value of the gliding value.
 
double getStandardDeviation () const
 To compute the standard deviation, we rely on the formula.
 
bool hasFullSetOfMeasurements () const
 
bool isAccurateValue (double factor=0.1) const
 Is value accurate.
 
void setValue (const double &value)
 Set the value.
 
std::string toString () const
 
double max () const
 
double min () const
 
void erase ()
 
int getObservationSpan () const
 

Static Public Attributes

static constexpr double DefaultWeight = 0.7
 

Private Attributes

const double _weight
 The weights q determine the weight via $q^0,q^1,q^2,...$.
 
const int _maxEntries
 
std::vector< double > _values
 Data.
 

Static Private Attributes

static tarch::logging::Log _log
 

Detailed Description

GlidingAverageMeasurement.

This is an alternative implementation to Measurement which uses a gliding average rather than the real average over all data. The gliding average is computed as follows:

\( m = \frac{ \sum _i w^i \cdot m_i }{ \sum _i w^i } \)

This w is the weight from the constructor. The \( m_i \) are the recorded measurements.

Author
Tobias Weinzierl

Definition at line 33 of file GlidingAverageMeasurement.h.

Constructor & Destructor Documentation

◆ GlidingAverageMeasurement()

tarch::timing::GlidingAverageMeasurement::GlidingAverageMeasurement ( double weight = DefaultWeight,
int maxEntries = 16 )

Construct a measurement with a gliding measurement.

Parameters
weightHas to be 0<weight<=1.0. See class description for details how this value is used.
maxEntriesHow many entries have to be taken into account. Has to bigger than one. You can pass in 1, but then it is not a gliding average, but just a value.

◆ ~GlidingAverageMeasurement()

tarch::timing::GlidingAverageMeasurement::~GlidingAverageMeasurement ( )
default

Member Function Documentation

◆ erase()

void tarch::timing::GlidingAverageMeasurement::erase ( )

◆ getObservationSpan()

int tarch::timing::GlidingAverageMeasurement::getObservationSpan ( ) const
Returns
How many values do feed into a single result, i.e. how many entries do we keep track of?

◆ getStandardDeviation()

double tarch::timing::GlidingAverageMeasurement::getStandardDeviation ( ) const

To compute the standard deviation, we rely on the formula.

sigma =sqrt( E(x^2) - E(x)^2 )

with E being the weighted mean value.

◆ getValue()

double tarch::timing::GlidingAverageMeasurement::getValue ( ) const

Return the value of the gliding value.

The formula is described in the class documentation. Note that the entries _values are ordered historically, i.e. _values[0] is the oldest value. That means we have to do some index magic compared to the sums in the class docu.

Returns
Value repreented by this gliding average.

◆ hasFullSetOfMeasurements()

bool tarch::timing::GlidingAverageMeasurement::hasFullSetOfMeasurements ( ) const
Returns
Number of setValue() calls has exceeded the maxEntries argument from the constructor

◆ isAccurateValue()

bool tarch::timing::GlidingAverageMeasurement::isAccurateValue ( double factor = 0.1) const

Is value accurate.

A value is accurate if its standard deviation divided by its mean is smaller than the factor.

◆ max()

double tarch::timing::GlidingAverageMeasurement::max ( ) const

◆ min()

double tarch::timing::GlidingAverageMeasurement::min ( ) const

◆ setValue()

void tarch::timing::GlidingAverageMeasurement::setValue ( const double & value)

Set the value.

If the measurement already holds a value, this value is not overwritten. Instead, the measurement accumulates all values and returns the average.

◆ toString()

std::string tarch::timing::GlidingAverageMeasurement::toString ( ) const

Field Documentation

◆ _log

tarch::logging::Log tarch::timing::GlidingAverageMeasurement::_log
staticprivate

Definition at line 35 of file GlidingAverageMeasurement.h.

◆ _maxEntries

const int tarch::timing::GlidingAverageMeasurement::_maxEntries
private

Definition at line 41 of file GlidingAverageMeasurement.h.

◆ _values

std::vector<double> tarch::timing::GlidingAverageMeasurement::_values
private

Data.

Definition at line 46 of file GlidingAverageMeasurement.h.

◆ _weight

const double tarch::timing::GlidingAverageMeasurement::_weight
private

The weights q determine the weight via $q^0,q^1,q^2,...$.

Definition at line 40 of file GlidingAverageMeasurement.h.

◆ DefaultWeight

constexpr double tarch::timing::GlidingAverageMeasurement::DefaultWeight = 0.7
staticconstexpr

Definition at line 49 of file GlidingAverageMeasurement.h.


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