20 _accumulatedValue(0.0),
22 _accumulatedSquares(0.0),
23 _numberOfMeasurements(0.0),
24 _isAccurateValue(false),
26 _max(-
std::numeric_limits<
double>::max()),
35 _accumulatedValue = 0.0;
36 _accumulatedSquares = 0.0;
37 _numberOfMeasurements = 0.0;
38 _isAccurateValue =
false;
39 _min = std::numeric_limits<double>::max();
40 _max = -std::numeric_limits<double>::max();
48 return _accumulatedValue / _numberOfMeasurements;
54 return (_accumulatedValue + newValue) / (_numberOfMeasurements + 1.0);
71 return getMeanValue();
81 return std::sqrt(
std::abs(_accumulatedSquares / _numberOfMeasurements - getMeanValue() * getMeanValue()));
106 ?
std::abs(getMeanValueOfNextStep(value) - getMeanValue())
107 :
std::abs(getMeanValueOfNextStep(value) / getMeanValue() - 1.0);
108 _isAccurateValue = _numberOfMeasurements > 0 && differenceDueToNewValue < _accuracy;
113 _minMeasurement = _numberOfMeasurements;
117 _maxMeasurement = _numberOfMeasurements;
120 _accumulatedValue += value;
121 _accumulatedSquares += value * value;
122 _numberOfMeasurements += 1.0;
128 <<
static_cast<int>(_numberOfMeasurements) <<
"th value = " << value <<
", current deviation="
129 << ((_accumulatedValue + value) / (_numberOfMeasurements + 1) - _accumulatedValue / _numberOfMeasurements)
130 <<
", accumulatedValue=" << _accumulatedValue <<
", _numberOfMeasurements" << _numberOfMeasurements
131 <<
", isAccurateValue=" << _isAccurateValue <<
", _accuracy=" << _accuracy
140 std::ostringstream msg;
142 if (_numberOfMeasurements > 0) {
148 <<
",#measurements=" << _numberOfMeasurements <<
",max=" << _max <<
"(value #"
149 << (
static_cast<int>(_maxMeasurement)) <<
")"
150 <<
",min=" << _min <<
"(value #" << (
static_cast<int>(_minMeasurement)) <<
")";
152 if (_numberOfMeasurements > 0) {
154 <<
",+" << (_max - getValue()) / getValue() * 100.0 <<
"%"
155 <<
",-" << (getValue() - _min) / getValue() * 100.0 <<
"%"
156 <<
",std-deviation=" << getStandardDeviation();
159 if (_accuracy > 0.0) {
160 msg <<
",eps=" << _accuracy;
161 if (!_isAccurateValue) {
162 msg <<
" [not a valid averaged value yet]";
164 msg <<
" [converged]";
#define assertionEquals(lhs, rhs)
#define assertion1(expr, param)
#define logDebug(methodName, logMacroMessageStream)
double getAccumulatedValue() const
Measurement(const double &accuracy=0.0)
void increaseAccuracy(const double &factor)
int getNumberOfMeasurements() const
void setAccuracy(const double &value)
double getMeanValueOfNextStep(double newValue) const
static tarch::logging::Log _log
double getStandardDeviation() const
We did face some seg faults (very rarely) where the parameter under the square root did become slight...
std::string toString() const
void setValue(const double &value)
Set the value.
double getAccuracy() const
bool isAccurateValue() const
Is value accurate.
double getMostRecentValue() const
double getMeanValue() const
static bool smaller(double lhs, double rhs, double tolerance=NUMERICAL_ZERO_DIFFERENCE) InlineMethod
Smaller operator for floating point values.
bool smallerEquals(double lhs, double rhs, double tolerance=NUMERICAL_ZERO_DIFFERENCE)
std::string toString(MemoryLocation value)