|
Peano
|
GlidingAverageMeasurement. More...
#include <GlidingAverageMeasurement.h>

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 |
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.
Definition at line 33 of file GlidingAverageMeasurement.h.
| tarch::timing::GlidingAverageMeasurement::GlidingAverageMeasurement | ( | double | weight = DefaultWeight, |
| int | maxEntries = 16 ) |
Construct a measurement with a gliding measurement.
| weight | Has to be 0<weight<=1.0. See class description for details how this value is used. |
| maxEntries | How 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. |
|
default |
| void tarch::timing::GlidingAverageMeasurement::erase | ( | ) |
| int tarch::timing::GlidingAverageMeasurement::getObservationSpan | ( | ) | const |
| 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.
| 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.
| bool tarch::timing::GlidingAverageMeasurement::hasFullSetOfMeasurements | ( | ) | const |
| 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.
| double tarch::timing::GlidingAverageMeasurement::max | ( | ) | const |
| double tarch::timing::GlidingAverageMeasurement::min | ( | ) | const |
| 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.
| std::string tarch::timing::GlidingAverageMeasurement::toString | ( | ) | const |
|
staticprivate |
Definition at line 35 of file GlidingAverageMeasurement.h.
|
private |
Definition at line 41 of file GlidingAverageMeasurement.h.
|
private |
Data.
Definition at line 46 of file GlidingAverageMeasurement.h.
|
private |
The weights q determine the weight via $q^0,q^1,q^2,...$.
Definition at line 40 of file GlidingAverageMeasurement.h.
|
staticconstexpr |
Definition at line 49 of file GlidingAverageMeasurement.h.