CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ( )

Definition at line 4 of file Accumulator.cc.

5 : sum_(0.),
6  sumOfSquares_(0.),
7  weightedSum_(0.),
8  sumOfWeights_(0.),
9  n_(0)
10 {
11 }
double weightedSum_
Definition: Accumulator.h:32
unsigned long n_
Definition: Accumulator.h:34
double sum_
Definition: Accumulator.h:30
double sumOfSquares_
Definition: Accumulator.h:31
double sumOfWeights_
Definition: Accumulator.h:33

Member Function Documentation

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

Definition at line 14 of file Accumulator.cc.

References n_, sum_, sumOfSquares_, sumOfWeights_, relativeConstraints::value, CommonMethods::weight(), and weightedSum_.

14  {
15  sum_ += value;
19  ++n_;
20 }
double weightedSum_
Definition: Accumulator.h:32
unsigned long n_
Definition: Accumulator.h:34
double sum_
Definition: Accumulator.h:30
double sumOfSquares_
Definition: Accumulator.h:31
double sumOfWeights_
Definition: Accumulator.h:33
double Accumulator::mean ( ) const

Definition at line 23 of file Accumulator.cc.

References n_, and sum_.

Referenced by operator<<(), and variance().

23  {
24  return sum_/n_;
25 }
unsigned long n_
Definition: Accumulator.h:34
double sum_
Definition: Accumulator.h:30
unsigned long Accumulator::nEntries ( ) const
inline

Definition at line 27 of file Accumulator.h.

References n_.

Referenced by operator<<().

27 {return n_;}
unsigned long n_
Definition: Accumulator.h:34
double Accumulator::sigma ( ) const
inline

Definition at line 23 of file Accumulator.h.

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

Referenced by operator<<().

23 {return std::sqrt(variance());}
T sqrt(T t)
Definition: SSEVec.h:46
double variance() const
Definition: Accumulator.cc:28
double Accumulator::variance ( ) const

Definition at line 28 of file Accumulator.cc.

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

Referenced by sigma().

28  {
29  double numerator = sumOfSquares_ - sum_*mean();
30  unsigned long denominator = n_-1;
31  return numerator/denominator;
32 }
double mean() const
Definition: Accumulator.cc:23
unsigned long n_
Definition: Accumulator.h:34
double sum_
Definition: Accumulator.h:30
double sumOfSquares_
Definition: Accumulator.h:31
double Accumulator::weightedMean ( ) const

Definition at line 35 of file Accumulator.cc.

References sumOfWeights_, and weightedSum_.

35  {
36  return weightedSum_ / sumOfWeights_;
37 }
double weightedSum_
Definition: Accumulator.h:32
double sumOfWeights_
Definition: Accumulator.h:33

Member Data Documentation

unsigned long Accumulator::n_
private

Definition at line 34 of file Accumulator.h.

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

double Accumulator::sum_
private

Definition at line 30 of file Accumulator.h.

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

double Accumulator::sumOfSquares_
private

Definition at line 31 of file Accumulator.h.

Referenced by addEntry(), and variance().

double Accumulator::sumOfWeights_
private

Definition at line 33 of file Accumulator.h.

Referenced by addEntry(), and weightedMean().

double Accumulator::weightedSum_
private

Definition at line 32 of file Accumulator.h.

Referenced by addEntry(), and weightedMean().