CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
Accumulator Class Reference

#include <Accumulator.h>

Public Member Functions

 Accumulator ()
 
void addEntry (double value, double weight=1.)
 
double mean () const
 
unsigned long nEntries () const
 
double sigma () const
 
double variance () const
 
double weightedMean () const
 

Private Attributes

unsigned long n_
 
double sum_
 
double sumOfSquares_
 
double sumOfWeights_
 
double weightedSum_
 

Detailed Description

For validation purposes. This program calculates mean and RMS of a distribution

Rick Wilkinson

Definition at line 12 of file Accumulator.h.

Constructor & Destructor Documentation

◆ Accumulator()

Accumulator::Accumulator ( )

Definition at line 4 of file Accumulator.cc.

4 : sum_(0.), sumOfSquares_(0.), weightedSum_(0.), sumOfWeights_(0.), n_(0) {}
double weightedSum_
Definition: Accumulator.h:31
unsigned long n_
Definition: Accumulator.h:33
double sum_
Definition: Accumulator.h:29
double sumOfSquares_
Definition: Accumulator.h:30
double sumOfWeights_
Definition: Accumulator.h:32

Member Function Documentation

◆ addEntry()

void Accumulator::addEntry ( double  value,
double  weight = 1. 
)

Definition at line 6 of file Accumulator.cc.

References n_, sum_, sumOfSquares_, sumOfWeights_, relativeConstraints::value, mps_merge::weight, and weightedSum_.

6  {
7  sum_ += value;
11  ++n_;
12 }
double weightedSum_
Definition: Accumulator.h:31
unsigned long n_
Definition: Accumulator.h:33
double sum_
Definition: Accumulator.h:29
Definition: value.py:1
double sumOfSquares_
Definition: Accumulator.h:30
double sumOfWeights_
Definition: Accumulator.h:32

◆ mean()

double Accumulator::mean ( ) const

Definition at line 14 of file Accumulator.cc.

References n_, and sum_.

Referenced by variance().

14 { return sum_ / n_; }
unsigned long n_
Definition: Accumulator.h:33
double sum_
Definition: Accumulator.h:29

◆ nEntries()

unsigned long Accumulator::nEntries ( ) const
inline

Definition at line 26 of file Accumulator.h.

References n_.

26 { return n_; }
unsigned long n_
Definition: Accumulator.h:33

◆ sigma()

double Accumulator::sigma ( ) const
inline

Definition at line 22 of file Accumulator.h.

References mathSSE::sqrt(), and variance().

22 { return std::sqrt(variance()); }
T sqrt(T t)
Definition: SSEVec.h:19
double variance() const
Definition: Accumulator.cc:16

◆ variance()

double Accumulator::variance ( ) const

Definition at line 16 of file Accumulator.cc.

References bTagMiniDQMDeepCSV::denominator, mean(), n_, bTagMiniDQMDeepCSV::numerator, sum_, and sumOfSquares_.

Referenced by sigma(), and average.Average::uncertainty().

16  {
17  double numerator = sumOfSquares_ - sum_ * mean();
18  unsigned long denominator = n_ - 1;
19  return numerator / denominator;
20 }
unsigned long n_
Definition: Accumulator.h:33
double sum_
Definition: Accumulator.h:29
double mean() const
Definition: Accumulator.cc:14
double sumOfSquares_
Definition: Accumulator.h:30

◆ weightedMean()

double Accumulator::weightedMean ( ) const

Definition at line 22 of file Accumulator.cc.

References sumOfWeights_, and weightedSum_.

22 { return weightedSum_ / sumOfWeights_; }
double weightedSum_
Definition: Accumulator.h:31
double sumOfWeights_
Definition: Accumulator.h:32

Member Data Documentation

◆ n_

unsigned long Accumulator::n_
private

Definition at line 33 of file Accumulator.h.

Referenced by addEntry(), mean(), nEntries(), and variance().

◆ sum_

double Accumulator::sum_
private

Definition at line 29 of file Accumulator.h.

Referenced by addEntry(), mean(), and variance().

◆ sumOfSquares_

double Accumulator::sumOfSquares_
private

Definition at line 30 of file Accumulator.h.

Referenced by addEntry(), and variance().

◆ sumOfWeights_

double Accumulator::sumOfWeights_
private

Definition at line 32 of file Accumulator.h.

Referenced by addEntry(), and weightedMean().

◆ weightedSum_

double Accumulator::weightedSum_
private

Definition at line 31 of file Accumulator.h.

Referenced by addEntry(), and weightedMean().