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

\Author 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) {}

Member Function Documentation

◆ addEntry()

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

Definition at line 6 of file Accumulator.cc.

6  {
7  sum_ += value;
11  ++n_;
12 }

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

◆ mean()

double Accumulator::mean ( ) const

Definition at line 14 of file Accumulator.cc.

14 { return sum_ / n_; }

References n_, and sum_.

Referenced by variance().

◆ nEntries()

unsigned long Accumulator::nEntries ( ) const
inline

Definition at line 26 of file Accumulator.h.

26 { return n_; }

References n_.

◆ sigma()

double Accumulator::sigma ( ) const
inline

Definition at line 22 of file Accumulator.h.

22 { return std::sqrt(variance()); }

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

◆ variance()

double Accumulator::variance ( ) const

Definition at line 16 of file Accumulator.cc.

16  {
17  double numerator = sumOfSquares_ - sum_ * mean();
18  unsigned long denominator = n_ - 1;
19  return numerator / denominator;
20 }

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

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

◆ weightedMean()

double Accumulator::weightedMean ( ) const

Definition at line 22 of file Accumulator.cc.

22 { return weightedSum_ / sumOfWeights_; }

References sumOfWeights_, and weightedSum_.

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().

Accumulator::weightedSum_
double weightedSum_
Definition: Accumulator.h:31
Accumulator::variance
double variance() const
Definition: Accumulator.cc:16
Accumulator::sumOfSquares_
double sumOfSquares_
Definition: Accumulator.h:30
mps_merge.weight
weight
Definition: mps_merge.py:88
Accumulator::n_
unsigned long n_
Definition: Accumulator.h:33
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
Accumulator::sum_
double sum_
Definition: Accumulator.h:29
Accumulator::mean
double mean() const
Definition: Accumulator.cc:14
value
Definition: value.py:1
HLTTauDQMOffline_cfi.numerator
numerator
Definition: HLTTauDQMOffline_cfi.py:179
HLTTauDQMOffline_cfi.denominator
denominator
Definition: HLTTauDQMOffline_cfi.py:180
relativeConstraints.value
value
Definition: relativeConstraints.py:53
Accumulator::sumOfWeights_
double sumOfWeights_
Definition: Accumulator.h:32