CMS 3D CMS Logo

Public Member Functions | Private Attributes

Accumulator Class Reference

#include <Accumulator.h>

List of all members.

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.

:  sum_(0.),
   sumOfSquares_(0.),
   weightedSum_(0.),
   sumOfWeights_(0.),
   n_(0)
{
}

Member Function Documentation

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

Definition at line 23 of file Accumulator.cc.

References n_, and sum_.

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

                               {
  return sum_/n_;
}
unsigned long Accumulator::nEntries ( ) const [inline]

Definition at line 27 of file Accumulator.h.

References n_.

Referenced by operator<<().

{return n_;}
double Accumulator::sigma ( ) const [inline]

Definition at line 23 of file Accumulator.h.

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

Referenced by operator<<().

{return std::sqrt(variance());}
double Accumulator::variance ( ) const

Definition at line 28 of file Accumulator.cc.

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

Referenced by sigma().

                                   {
  double numerator = sumOfSquares_ - sum_*mean();
  unsigned long denominator = n_-1;
  return numerator/denominator;
}
double Accumulator::weightedMean ( ) const

Definition at line 35 of file Accumulator.cc.

References sumOfWeights_, and weightedSum_.

                                        {
  return weightedSum_ / sumOfWeights_;
}

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