#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_ |
For validation purposes. This program calculates mean and RMS of a distribution
Rick Wilkinson
Definition at line 12 of file Accumulator.h.
Accumulator::Accumulator | ( | ) |
Definition at line 4 of file Accumulator.cc.
: sum_(0.), sumOfSquares_(0.), weightedSum_(0.), sumOfWeights_(0.), n_(0) { }
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_.
{ sum_ += value; sumOfSquares_ += (value*value); weightedSum_ += value*weight; sumOfWeights_ += weight; ++n_; }
double Accumulator::mean | ( | ) | const |
Definition at line 23 of file Accumulator.cc.
Referenced by operator<<(), and variance().
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<<().
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_; }
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().