yoda is hosted by Hepforge, IPPP Durham
YODA - Yet more Objects for Data Analysis 2.0.2
YODA::Estimate Class Reference

A point estimate (base class for the Estimate) More...

#include <Estimate.h>

Inheritance diagram for YODA::Estimate:
YODA::Estimate0D

Public Member Functions

Constructors
 Estimate ()
 Default constructor of a new distribution.
 
 Estimate (double v, std::map< std::string, std::pair< double, double > > &errors)
 Constructor to set an Estimate with a pre-filled state.
 
 Estimate (const double v, const std::pair< double, double > &e, const std::string &source="")
 Alternative constructor to set an Estimate with value and uncertainty.
 
 Estimate (const Estimate &toCopy)
 
 Estimate (Estimate &&toMove)
 
Estimateoperator= (const Estimate &toCopy) noexcept
 
Estimateoperator= (Estimate &&toMove) noexcept
 
Operators
Estimateadd (const Estimate &toAdd, const std::string &pat_uncorr="^stat|^uncor")
 Add two Estimates.
 
Estimateoperator+= (const Estimate &toAdd)
 
Estimatesubtract (const Estimate &toSubtract, const std::string &pat_uncorr="^stat|^uncor")
 Subtract one Estimate from another.
 
Estimateoperator-= (const Estimate &toSubtract)
 
Modifiers
void setValue (const double value) noexcept
 Set the central value of this estimator.
 
void setVal (const double val) noexcept
 Alias for setValue.
 
void setErr (const std::pair< double, double > &err, const std::string &source="")
 Set a signed uncertainty component.
 
void setErr (const double err, const std::string &source="")
 Set a symmetric uncertainty component.
 
void set (const double val, const std::pair< double, double > &err, const std::string source="")
 Set both central value and uncertainty component.
 
void set (const double val, const double err, const std::string &source="")
 Set both central value and uncertainty component.
 
void reset () noexcept
 Reset the internal values.
 
void scale (const double scalefactor) noexcept
 Rescale as if value and uncertainty had been different by factor scalefactor.
 
void scale (const Trf< 1 > &trf)
 Generalised transformations with functors.
 
void transform (const Trf< 1 > &trf)
 Generalised transformations with functors.
 
void renameSource (const std::string &old_label, const std::string &new_label)
 Replace a source label in the error breakdown.
 
void rmSource (const std::string &source)
 
void rmErrs ()
 
Estimate getters
double val () const noexcept
 The central value.
 
std::pair< double, double > errDownUp (const std::string &source="") const
 The signed absolute error on the central value.
 
std::pair< double, double > err (const std::string &source="") const
 Convenience alias for errorDownUp(source)
 
std::pair< double, double > errNegPos (std::string source="") const
 The signed negative and positive uncertainty component.
 
double errNeg (const std::string &source="") const
 The signed negative uncertainty component.
 
double errPos (const std::string &source="") const
 The signed positive uncertainty component.
 
double errDown (const std::string &source="") const
 The signed error due to the systematic downward variation.
 
double errUp (const std::string &source="") const
 The signed error due to the systematic upward variation.
 
double errAvg (const std::string &source="") const
 The unsigned error from an average of the downwards/upwards shifts.
 
double errEnv (const std::string &source="") const
 The unsigned symmetrised error from the largest component of the downwards/upwards shifts.
 
std::pair< double, double > relErrDownUp (const std::string &source="") const
 The relative signed error pair with respect to the central value.
 
std::pair< double, double > relErr (const std::string &source="") const
 Convenience alias for relErrDownUp.
 
double relErrDown (const std::string &source="") const
 The relative negative error with respect to the central value.
 
double relErrUp (const std::string &source="") const
 The relative positive error with respect to the central value.
 
double relErrAvg (const std::string &source="") const
 The relative uncertainty from an average of the downward/upward shifts with respect to the central value.
 
double relErrEnv (const std::string &source="") const
 The relative unsigned symmetrised error from the largest component of the downwards/upwards shifts with respect to the central value.
 
double valMax (const std::string &source="") const
 The maximal shift of the central value according to systematic variation source.
 
double valMin (const std::string &source="") const
 The minimal shift of the central value according to systematic variation source.
 
std::pair< double, double > quadSum (const std::string &pat_match="") const noexcept
 The quadrature sum of uncertainty components.
 
double quadSumNeg (const std::string &pat_match="") const noexcept
 The negative component of the quad-sum-based total uncertainty components.
 
double quadSumPos (const std::string &pat_match="") const noexcept
 The positive component of the quad-sum-based total uncertainty components.
 
double quadSumAvg (const std::string &pat_match="") const noexcept
 The unsigned average of the two quad-sum-based total uncertainty components.
 
double quadSumEnv (const std::string &pat_match="") const noexcept
 The unsigned symmetrised uncertainty from the largest of the quad-sum-based total uncertainty components.
 
double quadSumMax (const std::string &pat_match="") const
 The maximal shift of the central value from the quad-sum-based total uncertainty components.
 
double quadSumMin (const std::string &pat_match="") const
 The minimal shift of the central value from the quad-sum-based total uncertainty components.
 
std::pair< double, double > totalErr (const std::string &pat_match="") const noexcept
 The total uncertainty.
 
double totalErrNeg (const std::string &pat_match="") const noexcept
 The negative total uncertainty.
 
double totalErrPos (const std::string &pat_match="") const noexcept
 The positive total uncertainty.
 
double totalErrAvg (const std::string &pat_match="") const
 The average of the total downward/upward uncertainty shifts, which are taken to be the signed quadrature sums of the error sources.
 
double totalErrEnv (const std::string &pat_match="") const
 The unsigned symmetrised uncertainty from the largest of the downward/upward shifts of the quad-sum-based total uncertainty.
 
double totalErrMax (const std::string &pat_match="") const
 The maximal shift of the central value from the total uncertainty components.
 
double totalErrMin (const std::string &pat_match="") const
 The minimal shift of the central value from the total uncertainty components.
 
double valueErr (const std::string &pat_match="") const
 The unsigned average total uncertainty.
 
std::pair< double, double > relTotalErr (const std::string &pat_match="") const noexcept
 The relative negative/positive total uncertainty with respect to the central value.
 
double relTotalErrNeg (const std::string &pat_match="") const noexcept
 The relative negative total uncertainty on the central value.
 
double relTotalErrPos (const std::string &pat_match="") const noexcept
 The relative positive total uncertainty on the central value.
 
double relTotalErrAvg (const std::string &pat_match="") const noexcept
 The relative average of the quad-sum-based total downward/upward uncertainty components.
 
double relTotalErrEnv (const std::string &pat_match="") const noexcept
 The unsigned symmetrised error from the largest downward/upward components of the relative total quad-sum-based uncertainty.
 
std::vector< std::string > sources () const noexcept
 The list of error source names.
 
bool hasSource (const std::string &key) const noexcept
 Returns true/false if the error map contains key.
 
size_t numErrs () const noexcept
 The number of error sources in the error map.
 
MPI (de-)serialisation
std::vector< std::string > serializeSources () const noexcept
 
void deserializeSources (const std::vector< std::string > &data)
 

Detailed Description

A point estimate (base class for the Estimate)

This class is used internally by YODA to centralise the storage of static statistical results or estimators. Each estimate is made up of a value and an error map. The error map uses the source of uncertainty as the keys and the (possibly asymmetric) uncertainty pair as the values. The empty string is interpreted as the total uncertainty.

Definition at line 29 of file Estimate.h.

Constructor & Destructor Documentation

◆ Estimate() [1/5]

YODA::Estimate::Estimate ( )
inline

Default constructor of a new distribution.

Definition at line 36 of file Estimate.h.

36{ reset(); }
void reset() noexcept
Reset the internal values.
Definition Estimate.h:194

References reset().

◆ Estimate() [2/5]

YODA::Estimate::Estimate ( double  v,
std::map< std::string, std::pair< double, double > > &  errors 
)
inline

Constructor to set an Estimate with a pre-filled state.

Principally designed for internal persistency use.

Definition at line 42 of file Estimate.h.

43 : _value(v), _error(errors) { }

◆ Estimate() [3/5]

YODA::Estimate::Estimate ( const double  v,
const std::pair< double, double > &  e,
const std::string &  source = "" 
)
inline

Alternative constructor to set an Estimate with value and uncertainty.

Definition at line 47 of file Estimate.h.

48 : _value(v) { setErr(e, source); }
void setErr(const std::pair< double, double > &err, const std::string &source="")
Set a signed uncertainty component.
Definition Estimate.h:165

References setErr().

◆ Estimate() [4/5]

YODA::Estimate::Estimate ( const Estimate toCopy)
inline

Copy constructor

Sets all the parameters using the ones provided from an existing Estimate.

Definition at line 53 of file Estimate.h.

53 {
54 _value = toCopy._value;
55 _error = toCopy._error;
56 }

◆ Estimate() [5/5]

YODA::Estimate::Estimate ( Estimate &&  toMove)
inline

Move constructor

Sets all the parameters using the ones provided from an existing Estimate.

Definition at line 61 of file Estimate.h.

61 {
62 _value = std::move(toMove._value);
63 _error = std::move(toMove._error);
64 }

Member Function Documentation

◆ add()

Estimate & YODA::Estimate::add ( const Estimate toAdd,
const std::string &  pat_uncorr = "^stat|^uncor" 
)
inline

Add two Estimates.

Definition at line 95 of file Estimate.h.

95 {
96 setVal(val() + toAdd.val());
97 std::smatch match;
98 const std::regex re(pat_uncorr, std::regex_constants::icase);
99 for (const std::string& src : toAdd.sources()) {
100 if (!hasSource(src)) setErr(toAdd.errDownUp(src), src);
101 else if (std::regex_search(src, match, re)) {
102 // treat as uncorrelated between AOs:
103 // add in quadrature
104 const auto [l_dn,l_up] = errDownUp(src);
105 const auto [r_dn,r_up] = toAdd.errDownUp(src);
106 const double new_dn = std::sqrt(l_dn*l_dn + r_dn*r_dn);
107 const double new_up = std::sqrt(l_up*l_up + r_up*r_up);
108 setErr({-new_dn,new_up}, src);
109 }
110 else {
111 // treat as correlated between AOs: add linearly
112 const auto [l_dn,l_up] = errDownUp(src);
113 const auto [r_dn,r_up] = toAdd.errDownUp(src);
114 setErr({l_dn+r_dn, l_up+r_up}, src);
115 }
116 }
117 return *this;
118 }
std::vector< std::string > sources() const noexcept
The list of error source names.
Definition Estimate.h:487
double val() const noexcept
The central value.
Definition Estimate.h:249
void setVal(const double val) noexcept
Alias for setValue.
Definition Estimate.h:162
std::pair< double, double > errDownUp(const std::string &source="") const
The signed absolute error on the central value.
Definition Estimate.h:255
bool hasSource(const std::string &key) const noexcept
Returns true/false if the error map contains key.
Definition Estimate.h:494

References errDownUp(), hasSource(), setErr(), setVal(), sources(), and val().

Referenced by YODA::Estimate0D::add(), YODA::Estimate0D::add(), and operator+=().

◆ deserializeSources()

void YODA::Estimate::deserializeSources ( const std::vector< std::string > &  data)
inline

Definition at line 563 of file Estimate.h.

563 {
564
565 const size_t nErrs = numErrs();
566 if (data.size() != nErrs)
567 throw UserError("Expected " + std::to_string(nErrs) + " error source labels!");
568
569 for (size_t i = 0; i < data.size(); ++i) {
570 const std::string name("source" + std::to_string(i+1));
571 if (!_error.count(name))
572 throw UserError("Key names have already been updated!");
573 renameSource(name, data[i]);
574 }
575
576 }
size_t numErrs() const noexcept
The number of error sources in the error map.
Definition Estimate.h:499
void renameSource(const std::string &old_label, const std::string &new_label)
Replace a source label in the error breakdown.
Definition Estimate.h:219

References numErrs(), and renameSource().

◆ err()

std::pair< double, double > YODA::Estimate::err ( const std::string &  source = "") const
inline

Convenience alias for errorDownUp(source)

Definition at line 263 of file Estimate.h.

263 {
264 return errDownUp(source);
265 }

References errDownUp().

Referenced by set(), set(), setErr(), and setErr().

◆ errAvg()

double YODA::Estimate::errAvg ( const std::string &  source = "") const
inline

The unsigned error from an average of the downwards/upwards shifts.

Definition at line 293 of file Estimate.h.

293 {
294 return _average(errDownUp(source));
295 }

References errDownUp().

◆ errDown()

double YODA::Estimate::errDown ( const std::string &  source = "") const
inline

The signed error due to the systematic downward variation.

Definition at line 283 of file Estimate.h.

283 {
284 return errDownUp(source).first;
285 }

References errDownUp().

Referenced by YODA::divide().

◆ errDownUp()

std::pair< double, double > YODA::Estimate::errDownUp ( const std::string &  source = "") const
inline

The signed absolute error on the central value.

Note
first/second element corresponds to systematic down/up variation

Definition at line 255 of file Estimate.h.

255 {
256 const size_t count = _error.count(source);
257 if (!count)
258 throw RangeError("Error map has no such key: "+source);
259 return _error.at(source);
260 }

Referenced by add(), err(), errAvg(), errDown(), errEnv(), errNegPos(), errUp(), relErrDownUp(), and subtract().

◆ errEnv()

double YODA::Estimate::errEnv ( const std::string &  source = "") const
inline

The unsigned symmetrised error from the largest component of the downwards/upwards shifts.

Definition at line 299 of file Estimate.h.

299 {
300 return _envelope(errDownUp(source));
301 }

References errDownUp().

◆ errNeg()

double YODA::Estimate::errNeg ( const std::string &  source = "") const
inline

The signed negative uncertainty component.

Definition at line 273 of file Estimate.h.

273 {
274 return errNegPos(source).first;
275 }
std::pair< double, double > errNegPos(std::string source="") const
The signed negative and positive uncertainty component.
Definition Estimate.h:268

References errNegPos().

Referenced by valMin().

◆ errNegPos()

std::pair< double, double > YODA::Estimate::errNegPos ( std::string  source = "") const
inline

The signed negative and positive uncertainty component.

Definition at line 268 of file Estimate.h.

268 {
269 return _downUp2NegPos( errDownUp(source) );
270 }

References errDownUp().

Referenced by errNeg(), and errPos().

◆ errPos()

double YODA::Estimate::errPos ( const std::string &  source = "") const
inline

The signed positive uncertainty component.

Definition at line 278 of file Estimate.h.

278 {
279 return errNegPos(source).second;
280 }

References errNegPos().

Referenced by valMax().

◆ errUp()

double YODA::Estimate::errUp ( const std::string &  source = "") const
inline

The signed error due to the systematic upward variation.

Definition at line 288 of file Estimate.h.

288 {
289 return errDownUp(source).second;
290 }

References errDownUp().

Referenced by YODA::divide().

◆ hasSource()

bool YODA::Estimate::hasSource ( const std::string &  key) const
inlinenoexcept

Returns true/false if the error map contains key.

Definition at line 494 of file Estimate.h.

494 {
495 return _error.count(key);
496 }

Referenced by add(), YODA::divide(), renameSource(), rmSource(), and subtract().

◆ numErrs()

size_t YODA::Estimate::numErrs ( ) const
inlinenoexcept

The number of error sources in the error map.

Definition at line 499 of file Estimate.h.

499 {
500 return _error.size();
501 }

Referenced by deserializeSources(), and YODA::Estimate0D::mkInert().

◆ operator+=()

Estimate & YODA::Estimate::operator+= ( const Estimate toAdd)
inline

Definition at line 120 of file Estimate.h.

120 {
121 return add(toAdd);
122 }
Estimate & add(const Estimate &toAdd, const std::string &pat_uncorr="^stat|^uncor")
Add two Estimates.
Definition Estimate.h:95

References add().

◆ operator-=()

Estimate & YODA::Estimate::operator-= ( const Estimate toSubtract)
inline

Definition at line 149 of file Estimate.h.

149 {
150 return subtract(toSubtract);
151 }
Estimate & subtract(const Estimate &toSubtract, const std::string &pat_uncorr="^stat|^uncor")
Subtract one Estimate from another.
Definition Estimate.h:125

References subtract().

◆ operator=() [1/2]

Estimate & YODA::Estimate::operator= ( const Estimate toCopy)
inlinenoexcept

Copy assignment

Sets all the parameters using the ones provided from an existing Estimate.

Definition at line 69 of file Estimate.h.

69 {
70 if (this != &toCopy) {
71 _value = toCopy._value;
72 _error = toCopy._error;
73 }
74 return *this;
75 }

Referenced by YODA::Estimate0D::operator=(), and YODA::Estimate0D::operator=().

◆ operator=() [2/2]

Estimate & YODA::Estimate::operator= ( Estimate &&  toMove)
inlinenoexcept

Move assignment

Sets all the parameters using the ones provided from an existing Estimate.

Definition at line 80 of file Estimate.h.

80 {
81 if (this != &toMove) {
82 _value = std::move(toMove._value);
83 _error = std::move(toMove._error);
84 }
85 return *this;
86 }

◆ quadSum()

std::pair< double, double > YODA::Estimate::quadSum ( const std::string &  pat_match = "") const
inlinenoexcept

The quadrature sum of uncertainty components.

Note
The first element is for the negative error, the second element for the positive error.
In case of one-sided uncertainties, a zero-deviation is used for the null component.
if pat_match is supplied, only the subset of error sources matching the pattern are included.

Definition at line 358 of file Estimate.h.

358 {
359 const bool check_match = pat_match != ""; std::smatch match;
360 const std::regex re(pat_match, std::regex_constants::icase);
361 // interpret as { neg , pos } quad sums
362 std::pair<double, double> ret = { 0., 0. };
363 for (const auto& item : _error) {
364 if (item.first == "") continue;
365 if (check_match && !std::regex_search(item.first, match, re)) continue;
366 const auto [dn,up] = _downUp2NegPos(item.second);
367 ret.first += dn*dn;
368 ret.second += up*up;
369 }
370 return { - std::sqrt(ret.first), std::sqrt(ret.second) };
371 }

Referenced by quadSumAvg(), quadSumEnv(), quadSumNeg(), quadSumPos(), and totalErr().

◆ quadSumAvg()

double YODA::Estimate::quadSumAvg ( const std::string &  pat_match = "") const
inlinenoexcept

The unsigned average of the two quad-sum-based total uncertainty components.

Definition at line 384 of file Estimate.h.

384 {
385 return _average(quadSum(pat_match));
386 }
std::pair< double, double > quadSum(const std::string &pat_match="") const noexcept
The quadrature sum of uncertainty components.
Definition Estimate.h:358

References quadSum().

◆ quadSumEnv()

double YODA::Estimate::quadSumEnv ( const std::string &  pat_match = "") const
inlinenoexcept

The unsigned symmetrised uncertainty from the largest of the quad-sum-based total uncertainty components.

Definition at line 390 of file Estimate.h.

390 {
391 return _envelope(quadSum(pat_match));
392 }

References quadSum().

◆ quadSumMax()

double YODA::Estimate::quadSumMax ( const std::string &  pat_match = "") const
inline

The maximal shift of the central value from the quad-sum-based total uncertainty components.

Definition at line 396 of file Estimate.h.

396 {
397 return val() + quadSumPos(pat_match);
398 }
double quadSumPos(const std::string &pat_match="") const noexcept
The positive component of the quad-sum-based total uncertainty components.
Definition Estimate.h:379

References quadSumPos(), and val().

◆ quadSumMin()

double YODA::Estimate::quadSumMin ( const std::string &  pat_match = "") const
inline

The minimal shift of the central value from the quad-sum-based total uncertainty components.

Definition at line 402 of file Estimate.h.

402 {
403 return val() + quadSumNeg(pat_match);
404 }
double quadSumNeg(const std::string &pat_match="") const noexcept
The negative component of the quad-sum-based total uncertainty components.
Definition Estimate.h:374

References quadSumNeg(), and val().

◆ quadSumNeg()

double YODA::Estimate::quadSumNeg ( const std::string &  pat_match = "") const
inlinenoexcept

The negative component of the quad-sum-based total uncertainty components.

Definition at line 374 of file Estimate.h.

374 {
375 return quadSum(pat_match).first;
376 }

References quadSum().

Referenced by quadSumMin().

◆ quadSumPos()

double YODA::Estimate::quadSumPos ( const std::string &  pat_match = "") const
inlinenoexcept

The positive component of the quad-sum-based total uncertainty components.

Definition at line 379 of file Estimate.h.

379 {
380 return quadSum(pat_match).second;
381 }

References quadSum().

Referenced by quadSumMax().

◆ relErr()

std::pair< double, double > YODA::Estimate::relErr ( const std::string &  source = "") const
inline

Convenience alias for relErrDownUp.

Definition at line 312 of file Estimate.h.

312 {
313 return relErrDownUp(source);
314 }
std::pair< double, double > relErrDownUp(const std::string &source="") const
The relative signed error pair with respect to the central value.
Definition Estimate.h:304

References relErrDownUp().

Referenced by relErrDown(), and relErrUp().

◆ relErrAvg()

double YODA::Estimate::relErrAvg ( const std::string &  source = "") const
inline

The relative uncertainty from an average of the downward/upward shifts with respect to the central value.

Definition at line 328 of file Estimate.h.

328 {
329 return _average(relErrDownUp(source));
330 }

References relErrDownUp().

◆ relErrDown()

double YODA::Estimate::relErrDown ( const std::string &  source = "") const
inline

The relative negative error with respect to the central value.

Definition at line 317 of file Estimate.h.

317 {
318 return relErr(source).first;
319 }
std::pair< double, double > relErr(const std::string &source="") const
Convenience alias for relErrDownUp.
Definition Estimate.h:312

References relErr().

Referenced by YODA::divide().

◆ relErrDownUp()

std::pair< double, double > YODA::Estimate::relErrDownUp ( const std::string &  source = "") const
inline

The relative signed error pair with respect to the central value.

Definition at line 304 of file Estimate.h.

304 {
305 auto [dn,up] = errDownUp(source);
306 dn = _value != 0 ? dn/fabs(_value) : std::numeric_limits<double>::quiet_NaN();
307 up = _value != 0 ? up/fabs(_value) : std::numeric_limits<double>::quiet_NaN();
308 return {dn,up};
309 }

References errDownUp().

Referenced by relErr(), relErrAvg(), and relErrEnv().

◆ relErrEnv()

double YODA::Estimate::relErrEnv ( const std::string &  source = "") const
inline

The relative unsigned symmetrised error from the largest component of the downwards/upwards shifts with respect to the central value.

Definition at line 334 of file Estimate.h.

334 {
335 return _envelope(relErrDownUp(source));
336 }

References relErrDownUp().

◆ relErrUp()

double YODA::Estimate::relErrUp ( const std::string &  source = "") const
inline

The relative positive error with respect to the central value.

Definition at line 322 of file Estimate.h.

322 {
323 return relErr(source).second;
324 }

References relErr().

Referenced by YODA::divide().

◆ relTotalErr()

std::pair< double, double > YODA::Estimate::relTotalErr ( const std::string &  pat_match = "") const
inlinenoexcept

The relative negative/positive total uncertainty with respect to the central value.

Definition at line 457 of file Estimate.h.

457 {
458 auto [neg,pos] = totalErr(pat_match);
459 neg = _value != 0 ? neg/fabs(_value) : std::numeric_limits<double>::quiet_NaN();
460 pos = _value != 0 ? pos/fabs(_value) : std::numeric_limits<double>::quiet_NaN();
461 return {neg,pos};
462 }
std::pair< double, double > totalErr(const std::string &pat_match="") const noexcept
The total uncertainty.
Definition Estimate.h:410

References totalErr().

Referenced by relTotalErrAvg(), relTotalErrEnv(), relTotalErrNeg(), and relTotalErrPos().

◆ relTotalErrAvg()

double YODA::Estimate::relTotalErrAvg ( const std::string &  pat_match = "") const
inlinenoexcept

The relative average of the quad-sum-based total downward/upward uncertainty components.

Definition at line 476 of file Estimate.h.

476 {
477 return _average(relTotalErr(pat_match));
478 }
std::pair< double, double > relTotalErr(const std::string &pat_match="") const noexcept
The relative negative/positive total uncertainty with respect to the central value.
Definition Estimate.h:457

References relTotalErr().

Referenced by YODA::efficiency().

◆ relTotalErrEnv()

double YODA::Estimate::relTotalErrEnv ( const std::string &  pat_match = "") const
inlinenoexcept

The unsigned symmetrised error from the largest downward/upward components of the relative total quad-sum-based uncertainty.

Definition at line 482 of file Estimate.h.

482 {
483 return _envelope(relTotalErr(pat_match));
484 }

References relTotalErr().

◆ relTotalErrNeg()

double YODA::Estimate::relTotalErrNeg ( const std::string &  pat_match = "") const
inlinenoexcept

The relative negative total uncertainty on the central value.

Definition at line 465 of file Estimate.h.

465 {
466 return relTotalErr(pat_match).first;
467 }

References relTotalErr().

◆ relTotalErrPos()

double YODA::Estimate::relTotalErrPos ( const std::string &  pat_match = "") const
inlinenoexcept

The relative positive total uncertainty on the central value.

Definition at line 470 of file Estimate.h.

470 {
471 return relTotalErr(pat_match).second;
472 }

References relTotalErr().

◆ renameSource()

void YODA::Estimate::renameSource ( const std::string &  old_label,
const std::string &  new_label 
)
inline

Replace a source label in the error breakdown.

Definition at line 219 of file Estimate.h.

219 {
220 if (!hasSource(old_label)) {
221 throw UserError("Error map has no such key: "+old_label);
222 }
223 auto entry = _error.extract(old_label);
224 entry.key() = new_label;
225 _error.insert(std::move(entry));
226 }

References hasSource().

Referenced by deserializeSources(), and YODA::Estimate0D::mkInert().

◆ reset()

void YODA::Estimate::reset ( )
inlinenoexcept

Reset the internal values.

Definition at line 194 of file Estimate.h.

194 {
195 _value = std::numeric_limits<double>::quiet_NaN();
196 _error.clear();
197 }

Referenced by Estimate(), and YODA::Estimate0D::reset().

◆ rmErrs()

void YODA::Estimate::rmErrs ( )
inline

Definition at line 236 of file Estimate.h.

236 {
237 _error.clear();
238 }

◆ rmSource()

void YODA::Estimate::rmSource ( const std::string &  source)
inline

Definition at line 229 of file Estimate.h.

229 {
230 if (hasSource(source)) {
231 _error.erase(source);
232 }
233 }

References hasSource().

◆ scale() [1/2]

void YODA::Estimate::scale ( const double  scalefactor)
inlinenoexcept

Rescale as if value and uncertainty had been different by factor scalefactor.

Definition at line 201 of file Estimate.h.

201 {
202 _value *= scalefactor;
203 for (auto& item : _error) {
204 item.second = { item.second.first * scalefactor, item.second.second * scalefactor };
205 }
206 }

Referenced by transform().

◆ scale() [2/2]

void YODA::Estimate::scale ( const Trf< 1 > &  trf)
inline

Generalised transformations with functors.

Definition at line 209 of file Estimate.h.

209 {
210 trf.transform(_value, _error);
211 }

References YODA::Transformation< N, Args >::transform().

◆ serializeSources()

std::vector< std::string > YODA::Estimate::serializeSources ( ) const
inlinenoexcept

Definition at line 559 of file Estimate.h.

559 {
560 return sources();
561 }

References sources().

◆ set() [1/2]

void YODA::Estimate::set ( const double  val,
const double  err,
const std::string &  source = "" 
)
inline

Set both central value and uncertainty component.

Definition at line 188 of file Estimate.h.

188 {
189 setVal(val);
190 setErr(err, source);
191 }
std::pair< double, double > err(const std::string &source="") const
Convenience alias for errorDownUp(source)
Definition Estimate.h:263

References err(), setErr(), setVal(), and val().

◆ set() [2/2]

void YODA::Estimate::set ( const double  val,
const std::pair< double, double > &  err,
const std::string  source = "" 
)
inline

Set both central value and uncertainty component.

Definition at line 181 of file Estimate.h.

181 {
182 setVal(val);
183 setErr(err, source);
184 }

References err(), setErr(), setVal(), and val().

Referenced by YODA::divide(), and YODA::efficiency().

◆ setErr() [1/2]

void YODA::Estimate::setErr ( const double  err,
const std::string &  source = "" 
)
inline

Set a symmetric uncertainty component.

Note
The down-component will be set to -|err| and the up-component will be set to +|err|.

Definition at line 176 of file Estimate.h.

176 {
177 setErr({-fabs(err),fabs(err)}, source);
178 }

References err(), and setErr().

◆ setErr() [2/2]

void YODA::Estimate::setErr ( const std::pair< double, double > &  err,
const std::string &  source = "" 
)
inline

Set a signed uncertainty component.

Definition at line 165 of file Estimate.h.

165 {
166 const std::string& s = Utils::toUpper(source);
167 if (s == "TOTAL")
168 throw UserError("Use empty string for the total uncertainty!");
169 _error[source] = err;
170 }

References err().

Referenced by add(), YODA::divide(), YODA::efficiency(), Estimate(), YODA::Counter::mkEstimate(), set(), set(), setErr(), and subtract().

◆ setVal()

void YODA::Estimate::setVal ( const double  val)
inlinenoexcept

Alias for setValue.

Definition at line 162 of file Estimate.h.

162{ setValue(val); }
void setValue(const double value) noexcept
Set the central value of this estimator.
Definition Estimate.h:159

References setValue(), and val().

Referenced by add(), YODA::divide(), YODA::Counter::mkEstimate(), set(), set(), and subtract().

◆ setValue()

void YODA::Estimate::setValue ( const double  value)
inlinenoexcept

Set the central value of this estimator.

Definition at line 159 of file Estimate.h.

159{ _value = value; }

Referenced by setVal().

◆ sources()

std::vector< std::string > YODA::Estimate::sources ( ) const
inlinenoexcept

The list of error source names.

Definition at line 487 of file Estimate.h.

487 {
488 std::vector<std::string> keys;
489 for (const auto& item : _error) keys.push_back(item.first);
490 return keys;
491 }

Referenced by add(), YODA::divide(), YODA::efficiency(), serializeSources(), and subtract().

◆ subtract()

Estimate & YODA::Estimate::subtract ( const Estimate toSubtract,
const std::string &  pat_uncorr = "^stat|^uncor" 
)
inline

Subtract one Estimate from another.

Definition at line 125 of file Estimate.h.

125 {
126 setVal(val() - toSubtract.val());
127 std::smatch match;
128 const std::regex re(pat_uncorr, std::regex_constants::icase);
129 for (const std::string& src : toSubtract.sources()) {
130 if (!hasSource(src)) setErr(toSubtract.errDownUp(src), src);
131 else if (std::regex_search(src, match, re)) {
132 // treat as uncorrelated between AOs: add in quadrature
133 const auto [l_dn,l_up] = errDownUp(src);
134 const auto [r_dn,r_up] = toSubtract.errDownUp(src);
135 const double new_dn = std::sqrt(l_dn*l_dn + r_dn*r_dn);
136 const double new_up = std::sqrt(l_up*l_up + r_up*r_up);
137 setErr({-new_dn,new_up}, src);;
138 }
139 else {
140 // treat as correlated between AOs: add linearly
141 const auto [l_dn,l_up] = errDownUp(src);
142 const auto [r_dn,r_up] = toSubtract.errDownUp(src);
143 setErr({l_dn+r_dn, l_up+r_up}, src);
144 }
145 }
146 return *this;
147 }

References errDownUp(), hasSource(), setErr(), setVal(), sources(), and val().

Referenced by operator-=(), YODA::Estimate0D::subtract(), and YODA::Estimate0D::subtract().

◆ totalErr()

std::pair< double, double > YODA::Estimate::totalErr ( const std::string &  pat_match = "") const
inlinenoexcept

The total uncertainty.

Note
If the user didn't specify a total uncertainty using the empty string, the sum in quadrature is returned.

Definition at line 410 of file Estimate.h.

410 {
411 // check if the user specified the total uncertainty
412 if (pat_match == "" && _error.count("")) return _downUp2NegPos(_error.at(""));
413 // otherwise return quadrature sum
414 return quadSum(pat_match);
415 }

References quadSum().

Referenced by relTotalErr(), totalErrAvg(), totalErrEnv(), totalErrNeg(), and totalErrPos().

◆ totalErrAvg()

double YODA::Estimate::totalErrAvg ( const std::string &  pat_match = "") const
inline

The average of the total downward/upward uncertainty shifts, which are taken to be the signed quadrature sums of the error sources.

Definition at line 429 of file Estimate.h.

429 {
430 return _average(totalErr(pat_match));
431 }

References totalErr().

Referenced by YODA::efficiency(), and valueErr().

◆ totalErrEnv()

double YODA::Estimate::totalErrEnv ( const std::string &  pat_match = "") const
inline

The unsigned symmetrised uncertainty from the largest of the downward/upward shifts of the quad-sum-based total uncertainty.

Definition at line 435 of file Estimate.h.

435 {
436 return _envelope(totalErr(pat_match));
437 }

References totalErr().

◆ totalErrMax()

double YODA::Estimate::totalErrMax ( const std::string &  pat_match = "") const
inline

The maximal shift of the central value from the total uncertainty components.

Definition at line 441 of file Estimate.h.

441 {
442 return val() + totalErrPos(pat_match);
443 }
double totalErrPos(const std::string &pat_match="") const noexcept
The positive total uncertainty.
Definition Estimate.h:423

References totalErrPos(), and val().

◆ totalErrMin()

double YODA::Estimate::totalErrMin ( const std::string &  pat_match = "") const
inline

The minimal shift of the central value from the total uncertainty components.

Definition at line 447 of file Estimate.h.

447 {
448 return val() + totalErrNeg(pat_match);
449 }
double totalErrNeg(const std::string &pat_match="") const noexcept
The negative total uncertainty.
Definition Estimate.h:418

References totalErrNeg(), and val().

◆ totalErrNeg()

double YODA::Estimate::totalErrNeg ( const std::string &  pat_match = "") const
inlinenoexcept

The negative total uncertainty.

Definition at line 418 of file Estimate.h.

418 {
419 return totalErr(pat_match).first;
420 }

References totalErr().

Referenced by totalErrMin().

◆ totalErrPos()

double YODA::Estimate::totalErrPos ( const std::string &  pat_match = "") const
inlinenoexcept

The positive total uncertainty.

Definition at line 423 of file Estimate.h.

423 {
424 return totalErr(pat_match).second;
425 }

References totalErr().

Referenced by YODA::Estimate0D::mkScatter(), and totalErrMax().

◆ transform()

void YODA::Estimate::transform ( const Trf< 1 > &  trf)
inline

Generalised transformations with functors.

Definition at line 214 of file Estimate.h.

214 {
215 scale(trf);
216 }
void scale(const double scalefactor) noexcept
Rescale as if value and uncertainty had been different by factor scalefactor.
Definition Estimate.h:201

References scale().

Referenced by YODA::transform().

◆ val()

double YODA::Estimate::val ( ) const
inlinenoexcept

The central value.

Definition at line 249 of file Estimate.h.

249{ return _value; }

Referenced by add(), YODA::divide(), YODA::efficiency(), YODA::Estimate0D::mkScatter(), quadSumMax(), quadSumMin(), set(), set(), setVal(), subtract(), totalErrMax(), totalErrMin(), valMax(), and valMin().

◆ valMax()

double YODA::Estimate::valMax ( const std::string &  source = "") const
inline

The maximal shift of the central value according to systematic variation source.

Definition at line 340 of file Estimate.h.

340 {
341 return val() + errPos(source);
342 }
double errPos(const std::string &source="") const
The signed positive uncertainty component.
Definition Estimate.h:278

References errPos(), and val().

◆ valMin()

double YODA::Estimate::valMin ( const std::string &  source = "") const
inline

The minimal shift of the central value according to systematic variation source.

Definition at line 346 of file Estimate.h.

346 {
347 return val() + errNeg(source);
348 }
double errNeg(const std::string &source="") const
The signed negative uncertainty component.
Definition Estimate.h:273

References errNeg(), and val().

◆ valueErr()

double YODA::Estimate::valueErr ( const std::string &  pat_match = "") const
inline

The unsigned average total uncertainty.

Definition at line 452 of file Estimate.h.

452 {
453 return fabs(totalErrAvg(pat_match));
454 }
double totalErrAvg(const std::string &pat_match="") const
The average of the total downward/upward uncertainty shifts, which are taken to be the signed quadrat...
Definition Estimate.h:429

References totalErrAvg().


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