#include <CommonTools/Statistics/interface/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_ |
This program calculates mean and RMS of a distribution
Rick Wilkinson
Definition at line 12 of file Accumulator.h.
Accumulator::Accumulator | ( | ) |
Definition at line 5 of file Accumulator.cc.
00006 : sum_(0.), 00007 sumOfSquares_(0.), 00008 weightedSum_(0.), 00009 sumOfWeights_(0.), 00010 n_(0) 00011 { 00012 }
void Accumulator::addEntry | ( | double | value, | |
double | weight = 1. | |||
) |
Definition at line 15 of file Accumulator.cc.
References n_, sum_, sumOfSquares_, sumOfWeights_, and weightedSum_.
00015 { 00016 sum_ += value; 00017 sumOfSquares_ += (value*value); 00018 weightedSum_ += value*weight; 00019 sumOfWeights_ += weight; 00020 ++n_; 00021 }
double Accumulator::mean | ( | ) | const |
unsigned long Accumulator::nEntries | ( | ) | const [inline] |
Definition at line 27 of file Accumulator.h.
References n_.
Referenced by operator<<().
00027 {return n_;}
double Accumulator::sigma | ( | ) | const [inline] |
Definition at line 23 of file Accumulator.h.
References funct::sqrt(), and variance().
Referenced by operator<<().
double Accumulator::variance | ( | ) | const |
Definition at line 29 of file Accumulator.cc.
References mean(), n_, sum_, and sumOfSquares_.
Referenced by sigma().
00029 { 00030 double numerator = sumOfSquares_ - sum_*mean(); 00031 unsigned long denominator = n_-1; 00032 return numerator/denominator; 00033 }
double Accumulator::weightedMean | ( | ) | const |
Definition at line 36 of file Accumulator.cc.
References sumOfWeights_, and weightedSum_.
00036 { 00037 return weightedSum_ / sumOfWeights_; 00038 }
unsigned long Accumulator::n_ [private] |
Definition at line 34 of file Accumulator.h.
Referenced by addEntry(), mean(), nEntries(), and variance().
double Accumulator::sum_ [private] |
double Accumulator::sumOfSquares_ [private] |
double Accumulator::sumOfWeights_ [private] |
double Accumulator::weightedSum_ [private] |