CMS 3D CMS Logo

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

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

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

Definition at line 6 of file Accumulator.cc.

References n_, sum_, sumOfSquares_, sumOfWeights_, relativeConstraints::value, histoStyle::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
int weight
Definition: histoStyle.py:51
double sumOfSquares_
Definition: Accumulator.h:30
double sumOfWeights_
Definition: Accumulator.h:32
double Accumulator::mean ( ) const

Definition at line 14 of file Accumulator.cc.

References n_, and sum_.

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

14 { return sum_ / n_; }
unsigned long n_
Definition: Accumulator.h:33
double sum_
Definition: Accumulator.h:29
unsigned long Accumulator::nEntries ( ) const
inline

Definition at line 26 of file Accumulator.h.

References n_.

Referenced by operator<<().

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

Definition at line 22 of file Accumulator.h.

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

Referenced by operator<<().

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

Definition at line 16 of file Accumulator.cc.

References cuy::denominator, mean(), n_, cuy::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 }
list numerator
Definition: cuy.py:484
double mean() const
Definition: Accumulator.cc:14
unsigned long n_
Definition: Accumulator.h:33
double sum_
Definition: Accumulator.h:29
list denominator
Definition: cuy.py:485
double sumOfSquares_
Definition: Accumulator.h:30
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

unsigned long Accumulator::n_
private

Definition at line 33 of file Accumulator.h.

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

double Accumulator::sum_
private

Definition at line 29 of file Accumulator.h.

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

double Accumulator::sumOfSquares_
private

Definition at line 30 of file Accumulator.h.

Referenced by addEntry(), and variance().

double Accumulator::sumOfWeights_
private

Definition at line 32 of file Accumulator.h.

Referenced by addEntry(), and weightedMean().

double Accumulator::weightedSum_
private

Definition at line 31 of file Accumulator.h.

Referenced by addEntry(), and weightedMean().